本文整理自网络,侵删。
问题:判断特定字符是为单字节还是双字节
解决:
// mbSingleByte 单字节字符 mbLeadByte 双字节字符首字节 mbTrailByte 双字节字符尾字节
Edit1.Text:='0102030405060708我1112131415';
n:=Length(WideString(Edit1.Text));
ShowMessage(IntToStr(n));
if ByteType(Edit1.Text,17)=mbLeadByte then
begin
//ShowMessage('汉字');
str:=leftstr(Edit1.Text,16)+' '+rightstr(Edit1.Text,n-16);
ShowMessage(str);
end
else if ByteType(Edit1.Text,17)=mbSingleByte then
begin
ShowMessage('字母');
end;
相关阅读 >>
Delphi 使用 inputbox、inputquery 的启发
Delphi windows 编程[21] - wm_menuselect 消息与 getmenustring 函数
更多相关阅读请进入《Delphi》频道 >>