本文整理自网络,侵删。
//根据国标 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 tms web core webhttprequest1 解析json
在Delphi如何实现模拟组合按键,如发送ctrl_f的按键消息
更多相关阅读请进入《Delphi》频道 >>