[fpc-devel] new string - question on usage

Paul Ishenin ip at kmiac.ru
Thu Oct 13 05:22:46 CEST 2011


13.10.2011 9:13, Hans-Peter Diettrich wrote:
> Sven Barth schrieb:
>
>> http://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/rtl/inc/astrings.inc?revision=19444&view=markup
>>
>
> I don't understand the use of encoding 0 and CP_NONE in FPC. Can
> somebody explain?

DefaultSystemCodepage is used When the paticular encoding must be known 
both for 0 and CP_NONE codepages.

> Furthermore I suspect that the implementation of
>
> Function Pos(Const Substr : RawByteString; Const Source : RawByteString)
> : SizeInt;
>
> is wrong. The comparison must take into account the encodings of both
> strings.
>
>
> Function Pos(c : AnsiChar; Const s : RawByteString) : SizeInt;
> is questionable at all, when the encoding of the arguments is unknown or
> ignored (as is).

Did you run some tests in delphi for these functions?

Please run the next program to be sure:

{$apptype console}

type
   T866Sting = type AnsiString(866);
   T1251String = type AnsiString(1251);
var
   s866: T866Sting;
   s1251: T1251String;
begin
   s866 := 'привет';
   writeln(s866);
   s1251 := 'рив';
   writeln(s1251);
   writeln(pos(s1251, s866));
end.

> I have the bad impression that the implementors didn't understand the
> purpose and correct use of RawByteString, or try to implement something
> incompatible with Delphi :-(

Do you base your impression on paticular knowlege of how delphi RTL 
works or only on your ideas of how it should work?

Best regards,
Paul Ishenin.




More information about the fpc-devel mailing list