fpc/tests/webtbs/tw18075.pp
paul a26bc50ca6 compiler: change ShortString->(Some)String and AnsiString->(Some)String overload precedence both for variables and string constants, change unicode constant type from widestring to unicodestring (Delphi compatibility)
new ShortString->(Some)String precedence: ShortString, UTF8String, AnsiString, AnsiString(CodePage) and RawByteString, UnicodeString, WideString and other string types
new AnsiString->(Some)String precedence: RawByteString, UTF8String, AnsiString, AnsiString(CodePage), UnicodeString, WideString, ShortString and other string types

The new logic makes UTF8String more preferrable than other AnsiString types, AnsiString more preferrable than other  AnsiStrings(codepage) and also makes UnicodeString more preferrable than WideString.

git-svn-id: trunk@21057 -
2012-04-26 02:33:57 +00:00

38 lines
659 B
ObjectPascal

{$codepage UTf8}
Var cad1:unicodeString;
cad2:Widestring;
n:integer;
Begin
cad1:='犮犯狃狄狪独';
cad2:=cad1;
//Unicodestring, 1 character is ok
Writeln('unicodestring');
n:=pos('犮',cad1);
Writeln(n);
if n<>1 then
halt(1);
Writeln('widestring');
n:=pos('犮',cad2);
Writeln(n);
if n<>1 then
halt(1);
//Unicodestring, more charactere wrong
Writeln('unicodestring');
n:=pos('狃狄',cad1);
Writeln(n); //show position 0
if n<>3 then
halt(1);
Writeln('widestring');
n:=pos(WideString('狃狄'),cad2); //Is correct position 3
Writeln(n);
if n<>3 then
halt(1);
Writeln('ok');
End.