CharInSet不适用于非英文字母吗? [英] CharInSet doesn't work with non English letters?

查看:240
本文介绍了CharInSet不适用于非英文字母吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经将一个应用程序从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

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不适用于非英文字母吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆