Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Bad Pos. Missing warning?

1 view
Skip to first unread message

Hamer

unread,
May 24, 2008, 4:23:26 PM5/24/08
to
Why don't I get a warning in the following construction?

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';

Bernhard Geyer

unread,
May 25, 2008, 3:20:54 AM5/25/08
to
Hamer schrieb:

Try

LWideChar := WideString('๘');

Hamer

unread,
May 25, 2008, 5:13:21 AM5/25/08
to
> 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;

>


> 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.

0 new messages