procedure TForm6.Button1Click(Sender: TObject);
const
cConst = '1?2';
var
LWideChar: WideChar;
begin
LWideChar := '๘'; // Some unicode char
if Pos(LWideChar, cConst) > 0 then
ShowMessage('Bug!!');
end;
cConst is a string with three chars, a question mark in the middle.
LWideChar is a unicode character, for example a Thai symbol.
In the Pos ? is equal to ๘.
Solution is to change the string to a widestring:
const
cConst: WideString = '1?2';
Try
LWideChar := WideString('๘');
>
> Try
>
> LWideChar := WideString('๘');
This doesn't compile. But if LWideChar is a widestring, the Pos function
works correct.
Only in my example the Pos goes wrong.
This unexpected behavior (implicit typecast) due to the missing warning is
not important in Delphi 2008 I suppose, so I won't file a QC report.