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;

相关阅读 >>

Delphi 语言字符集

Delphi yearof 根据指定的日期返回年

Delphi显示jpg、png、gif图片

Delphi 数组竟然可以这样定义

Delphi使用idhttp模拟提交页面方法总结

Delphi 遍历系统窗口标题可用于反外挂反破解

Delphi 使用indy解决tidssliohandlersocketopenssl could not load ssl library错误

Delphi 图像二值化

Delphi 使用钩子函数

Delphi android实例-trectangle加载图片(xe8+小米2)

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



打赏

取消

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

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

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

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

评论

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