delphi 判断字符是否是汉字  
官方Delphi 学习QQ群: 682628230(三千人)
频道

delphi 判断字符是否是汉字


//判断字符是否是汉字 
function IsHZ(ch: WideChar): boolean; 
var 
i:integer; 
begin 
i:=ord(ch); 
if( i<19968) or (i>40869) then 
result:=false else result:=true; 
end; 
//判断字符是否是汉字
function IsHZ(ch: WideChar): boolean;
var
i:integer;
begin
i:=ord(ch);
if( i<19968) or (i>40869) then
result:=false else result:=true;
end;
2005年1月28日:感谢滚龙的指点,已将代码改写如下:
view plaincopy to clipboardprint?
//判断字符是否是汉字 
function TForm1.IsHZ(ch: Char): boolean; 
begin 
//返回值为 0 的时候为单字节字符,返回值为 1 的时候为多字节字符 
if(ord(bytetype(ch,1))=1) then result:=true 
else result:=false; 
end; 
//判断字符是否是汉字
function TForm1.IsHZ(ch: Char): boolean;
begin
//返回值为 0 的时候为单字节字符,返回值为 1 的时候为多字节字符
if(ord(bytetype(ch,1))=1) then result:=true
else result:=false;
end;
2005年1月31日:谢谢滚龙再次赐教,代码已收藏!
view plaincopy to clipboardprint?
//判断字符是否是汉字 
function IsMBCSChar(const ch: Char): Boolean; 
begin 
Result := (ByteType(ch, 1) <> mbSingleByte); 
end; 
推荐分享
图文皆来源于网络,内容仅做公益性分享,版权归原作者所有,如有侵权请告知删除!
 

Copyright © 2014 DelphiW.com 开发 源码 文档 技巧 All Rights Reserved
晋ICP备14006235号-8 晋公网安备 14108102000087号

执行时间: 0.044554948806763 seconds