+ function IsASCII(const s: AnsiString): Boolean;
+ var i: Integer;
+ begin
+ for i := 1 to Length(s) do
+ begin
+ if s[i] >= #$80 then
+ begin
+ Result := False;
+ exit;
+ end;
+ end;
+ Result := True;
+ end;
+
+ function IsUTF8(const s: AnsiString): Boolean;
+ var i, j, len: Integer;
+ begin
+ Result := False;
+ i := 1; len := Length(s);
+ while i <= len do
+ begin
+ case Ord(s[i]) of
+ $00..$7F: j := 0;
+ $80..$BF: exit; // invalid encoding
+ $C0..$DF: j := 1;
+ $E0..$EF: j := 2;
+ $F0..$F7: j := 3;
+ otherwise exit; // invalid encoding
+ end;
+ Inc(i);
+ while j > 0 do
+ begin
+ if i > len then exit; // invlid length
+ case Ord(s[i]) of
+ $80..$BF: ; // ok
+ else exit; // invalid encoding
+ end;
+ Inc(i);
+ Dec(j);
+ end;
+ end;
+ Result := True;
+ end;
+
+ function DosToStr(dostime: UInt32): AnsiString;
+ begin
+ try
+ DateTimeToString(Result, 'yyyy/mm/dd hh:nn:ss', DosDateTimeToDateTime(dostime));
+ except on e: EConvertError do
+ Result := 'INVALID ($' + IntToHex(dostime, 8) + ')';
+ end;
+ end;
+