本文介绍了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')

然而,我知道在不会,所以我改成了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.Text1 使用 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 不适用于非英文字母?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-10 02:17