I have updated an application from Delphi 2007 to Delphi 2010, everything went fine, except one statement that compiled fine but not working which is:
If Edit1.T
This happens because set of char
structured type (limited to 256 elements maximum) doesn't support Unicode at all. That is, any characters Ord(ch) > High(AnsiChar)
being truncated in the set constructor and warning W1061 about narrowing WideChar to AnsiChar is being emitted. Look at the following testcase:
{ naturally, fails, emits CharInSet() suggestion }
Result := 'س' in ['S','س'];
{ fails because second argument is set of AnsiChar }
Result := CharInSet(
'س',
['S','س']
);
{ workaround for WideChar in AnsiCharSet, fails }
Result := WideStrUtils.InOpSet(
'س',
['S','س']
);
{ a syntactical workaround, which finally works }
Result := WideStrUtils.InOpArray(
'س',
['S','س']
);
if Result then
ShowMessage('PASS')
else
ShowMessage('FAIL');