我已将一个应用程序从Delphi 2007更新到Delphi 2010,一切都很顺利,除了一个被编译通过但无法正常工作的语句:
If Edit1.Text[1] in ['S','س'] then
ShowMessage('Found')
else
ShowMessage('Not Found')
但我知道它不会这样,所以我改用了CharInSet
If CharinSet(Edit1.Text[1],['S','س']) then
ShowMessage('Found')
else
ShowMessage('Not Found')
当字符串为س
时,它从未起作用过,但是对于S
总是有效的,即使我使用AnsiChar转换edt1.Text1,它仍然不能处理阿拉伯字母。
我做错了什么,或者CharInSet
的工作方式不对吗?还是CharinSet
中存在bug?
更新:
我的好朋友Issam Ali 提出了另一种解决方案,它已经运行良好:
If CharinSet(AnsiString(edt1.Text)[1],['S','س']) then