多春鱼小屋

登录
记住密码
  1. 首页
  2. [转]Unicode 检查字符串是否含中文字
[转]Unicode 检查字符串是否含中文字
发布 | 2016-3-8 | 评论数:0 | 阅读数:3716 | 标签:Delphi
// 字串含中文 by Aone
function IsIncludeChinese(Str: String): Boolean;
var i: Integer;
    UCS4Str: UCS4String;
begin
     Result := False;
     UCS4Str := UnicodeStringToUCS4String(Str);

     for i:=Low(UCS4Str) to High(UCS4Str) do
         if ((UCS4Str[i] >=  $3400) and (UCS4Str[i] <=  $4DB5)) or   // CJK Unified Ideographs Extension A 3.0
            ((UCS4Str[i] >=  $4E00) and (UCS4Str[i] <=  $9FA5)) or   // CJK Unified Ideographs 1.1
            ((UCS4Str[i] >=  $9FA6) and (UCS4Str[i] <=  $9FBB)) or   // CJK Unified Ideographs 4.1
            ((UCS4Str[i] >=  $F900) and (UCS4Str[i] <=  $FA2D)) or   // CJK Compatibility Ideographs 1.1
            ((UCS4Str[i] >=  $FA30) and (UCS4Str[i] <=  $FA6A)) or   // CJK Compatibility Ideographs 3.2
            ((UCS4Str[i] >=  $FA70) and (UCS4Str[i] <=  $FAD9)) or   // CJK Compatibility Ideographs 4.1
            ((UCS4Str[i] >= $20000) and (UCS4Str[i] <= $2A6D6)) or   // CJK Unified Ideographs Extension B 3.1
            ((UCS4Str[i] >= $2F800) and (UCS4Str[i] <= $2FA1D)) then // CJK Compatibility Supplement
            Exit(True);

end;

原文在此

分享至:

本文已关闭评论

  • 评论0
  • 粉丝1
  • 文章33

    • 多春鱼
    • 广州
    • 1970年2月26日
    • 联系 :capelin@qq.com 微信:imcapelin
    • 查看更多 >
    热门文章
    标签
    Delphi Android PHP Tools