问题描述
我已经将一个应用程序从Delphi 2007更新到了Delphi 2010,一切正常,除了一个可以编译但不能正常工作的语句是:
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.Text[1] in ['S','س'] then
ShowMessage('Found')
else
ShowMessage('Not Found')
但是,我知道in不会,所以我改成CharInSet
However, I knew that in will not, so I changed to CharInSet
If CharinSet(Edit1.Text[1],['S','س']) then
ShowMessage('Found')
else
ShowMessage('Not Found')
,但是当字符串为س
时它永远无法工作,但始终与S
一起工作,即使我强制转换edt1.Text 1 与AnsiChar结合使用,始终无法使用阿拉伯字母.
but it never worked when the string is س
, but always work with S
, even I cast the edt1.Text1 with AnsiChar it always not work Arabic letters.
是在做错什么,还是不是CharInSet
的工作方式?还是在CharinSet
中的错误?
Am doing anything wrong, or it's not the way CharInSet
works?, or that's a bug in CharinSet
?
更新:
我的好朋友 Issam Ali 提出了另一种效果很好的解决方案:
My Great friend Issam Ali has suggested another solution which's worked fine as it :
If CharinSet(AnsiString(edt1.Text)[1],['S','س']) then
推荐答案
CharInSet对于255以上的字符无效.在您的情况下,您应该使用
CharInSet is useless for the characters above 255. In your case you should use
case C of
'S','س' : ShowMessage('Found');
end;
这篇关于CharInSet不适用于非英文字母吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!