程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> Delphi >> Unicode 檢查字符串是否含中文字(函數),unicode字符串

Unicode 檢查字符串是否含中文字(函數),unicode字符串

編輯:Delphi

Unicode 檢查字符串是否含中文字(函數),unicode字符串


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

 

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved