如何判断可见字符 Unicode
一个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;
[解决办法]
二楼讲得很详细了,我们也学习了。
[解决办法]