本文整理自网络,侵删。
问题:判断特定字符是为单字节还是双字节
解决:
// 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 d10.x安卓app开发中简单使用原生toast
Delphi分别连接ms sqlserver、oracle和access数据库的连接字符串
Delphi winapi: openprocess、getexitcodeprocess、terminateprocess (qq)
Delphi 中将tmemorystream转换为'string'
Delphi xe7组件tetheringmanager1发送消息
更多相关阅读请进入《Delphi》频道 >>