unit ProbeTextProvider; {$mode objfpc}{$H+} interface uses ProbeReport; procedure RunTextProviderChecks(Report:TProbeReport); implementation uses SysUtils; function ByteEqual(const S:RawByteString;const B:array of Byte):Boolean; var I:Integer; begin Result:=Length(S)=Length(B);if not Result then Exit; for I:=0 to High(B) do if Byte(S[I+1])<>B[I] then Exit(False); end; procedure RunTextProviderChecks(Report:TProbeReport); const CP1251Bytes:array[0..5] of Byte=($CF,$F0,$E8,$E2,$E5,$F2); var A,Back:RawByteString;U:UnicodeString;I:Integer;OkDecode,OkEncode:Boolean; begin try SetLength(A,Length(CP1251Bytes));for I:=0 to High(CP1251Bytes) do A[I+1]:=AnsiChar(CP1251Bytes[I]); SetCodePage(A,1251,False);U:=UnicodeString(A); OkDecode:=(Length(U)=6) and (Ord(U[1])=$041F) and (Ord(U[2])=$0440) and (Ord(U[3])=$0438) and (Ord(U[4])=$0432) and (Ord(U[5])=$0435) and (Ord(U[6])=$0442); Report.Add('decision.text.cp1251_decode','OBSERVED', 'supported='+LowerCase(BoolToStr(OkDecode,True))+'; source_codepage='+IntToStr(StringCodePage(A))); Back:=UTF8Encode(U);SetCodePage(Back,1251,True);OkEncode:=ByteEqual(Back,CP1251Bytes); Report.Add('decision.text.cp1251_encode','OBSERVED', 'supported='+LowerCase(BoolToStr(OkEncode,True))+'; result_codepage='+IntToStr(StringCodePage(Back))); except on E:Exception do begin Report.Add('decision.text.cp1251_decode','OBSERVED','supported=false; error='+E.ClassName+': '+E.Message); Report.Add('decision.text.cp1251_encode','OBSERVED','supported=false; error='+E.ClassName+': '+E.Message); end; end; end; end.