码迷,mamicode.com
首页 > 其他好文 > 详细

Unicode 检查字符串是否含中文字(函数)

时间:2016-03-02 17:55:41      阅读:120      评论:0      收藏:0      [点我收藏+]

标签:

// 字串含中文 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;

 

Unicode 检查字符串是否含中文字(函数)

标签:

原文地址:http://www.cnblogs.com/onechen/p/5235696.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!