CharInSet不适用于非英文字母?

Moh*_*man 16 delphi unicode arabic delphi-2010

我已经将Delphi 2007的应用程序更新到了Delphi 2010,一切都很顺利,除了一个编译正常但不能正常工作的语句:

If Edit1.Text[1] in ['S','?'] then 
  ShowMessage('Found')
else
  ShowMessage('Not Found')
Run Code Online (Sandbox Code Playgroud)

但是,我知道不会,所以我改为 CharInSet

If CharinSet(Edit1.Text[1],['S','?']) then
  ShowMessage('Found')
else
  ShowMessage('Not Found')
Run Code Online (Sandbox Code Playgroud)

但它永远不会工作当字符串?,但总是使用S,即使我使用AnsiChar 转换edt1.Text 1它总是不工作阿拉伯字母.

我做错了什么,或者这不是CharInSet可行的方式?,或者那是一个错误CharinSet

更新:

我的好朋友伊萨姆·阿里提出了另一个解决方案,它的工作正常:

  If CharinSet(AnsiString(edt1.Text)[1],['S','?']) then
Run Code Online (Sandbox Code Playgroud)

klu*_*udg 17

对于255以上的字符,CharInSet是无用的.在你的情况下你应该使用

  case C of
    'S','?' : ShowMessage('Found');
  end;
Run Code Online (Sandbox Code Playgroud)