Delphi判断一个字符是否为汉字的最佳方法

时间:2023-03-09 08:52:43
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; //判断字符是否是汉字
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; //判断字符是否是汉字
function IsMBCSChar(const ch: Char): Boolean;
begin
Result := (ByteType(ch, 1) <> mbSingleByte);
end;