【问题标题】:Free Pascal: detect "is word char" for WideCharFree Pascal:检测 WideChar 的“is word char”
【发布时间】:2015-03-13 05:25:01
【问题描述】:

我使用代码

Result:=
((ch>='0') and (ch<='9')) or
((ch>='a') and (ch<='z')) or
((ch>='A') and (ch<='Z')) or
(ch='_');

它检测到 ok AnsiChar;如何检测 WideChar 的“if char letter or digit”?

【问题讨论】:

    标签: lazarus freepascal


    【解决方案1】:

    我想没有简单的方法可以解决这个问题。你对字母的定义是什么? Ω(欧米茄)是一个字母吗?它只是一个象征吗?您必须手动决定什么是字母,什么不是。你可以做一个大的case语句来确定一个char是否是字母数字......

    function is_alpha_num(ch : widechar) : boolean;
    begin
      case ch of
        #$0030..#$0039, // '0'..'9'                                                 
        #$0041..#$005A, // 'A'..'Z'                                                 
        #$0061..#$007A, // 'a'..'z'                                                 
        // need to define the rest here...                                          
        #$FF21..#$FF3A // 'A'..'Z'                                                
        : result := true;
       else result := false;
      end;
    end;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-12-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-26
      • 2012-09-14
      • 1970-01-01
      相关资源
      最近更新 更多