delphi 如何判断可见字符 Unicode  
官方Delphi 学习QQ群: 682628230(三千人)
频道

delphi 如何判断可见字符 Unicode


//根据国标 GB2312 的中文汉字及符号 区位码的范围判断
Function CheckIsGB2312(Char : WideChar) : Boolean;
var
  S : AnsiString;
begin
  S := Char;
  Result := (PByte(integer(S)+1)^>=$A1) and (PByte(integer(S)+1)^<=$FE) and
            (PByte(S)^>=$B0) and (PByte(S)^<=$F7);
end;

//检查是否都是可见英文字符或者汉字及符号,全部是返回True否则False,空格认为可见
Function StrIsCanShow(Const WS : WideString) : Boolean;
var
  i : integer;
  P : PWideChar;
begin
  Result := True;
  P := Pointer(WS);
  for i:=1 to Length(WS) do begin
    if not (
             ((PWord(P)^>=$20) and (PWord(P)^<=$7E)) //Ansi 可见字符
             or CheckIsGB2312(P^)                    //GB2312汉字及符号
           ) then  begin
      Result := False;
      Break;
    end;
    Inc(P);
  end;
end;


推荐分享
图文皆来源于网络,内容仅做公益性分享,版权归原作者所有,如有侵权请告知删除!
 

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

执行时间: 0.052299976348877 seconds