本文整理自网络,侵删。
//判断字符是否是汉字
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 tdragimage v0.1 Delphi 图片拖拽组件 带有加速度 碰撞效果
Delphi winapi: getwindowtext - 获取窗口标题
Delphi sysutils.isdelimiter - 判断字符串的某个位置是不是指定的字符串
Delphi combobox 只读 text属性可用的方法
Delphi xe android 调试错误:connection closed gracefully
Delphi获取dos命令行输出函数 运行cmd命令并获取结果
更多相关阅读请进入《Delphi》频道 >>