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; 

相关阅读 >>

Delphi 获取计算机名称 函数

Delphi 从资源文件中加载字符

Delphi使用hough变换查找直线

Delphi label设置为背景透明

Delphi 截取绝对路径的文件名

Delphi winsock远程唤醒计算机的函数

Delphi arp攻击代码

Delphi应用程序 paramstr()带有参数

Delphi以二进制方式读取图片并显示出来

Delphi 隐藏进程的单元 unit hideprocess.pas

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...