Delphi截取字符串 防止中文截断


本文整理自网络,侵删。

 
function GetText(strtxt:string;iLen:integer):string;
begin
//先判断要截取的字符串最后一个字节的类型
//如果为汉字的第一个字节则减(加)一位
if ByteType(strtxt,iLen) = mbLeadByte then 
iLen := iLen - 1;
result := copy(strtxt,1,iLen) + ’...‘;
end;

相关阅读 >>

Delphi中showmodal 和 show 的区别

Delphi dateutils功能详解

Delphi 获取cpu占用时间

Delphi 从网址链接中提取域名

Delphi idhttp的基本用法

Delphi输入汉字自动产生拼音简码

Delphi 7 + gdiplus 简单实现双缓冲绘制移动图形

Delphi10.3.1安卓照相

Delphi byte数组根据utf8 转换为string

Delphi xe5 android 使用system.zip单元释放资源文件

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



打赏

取消

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

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

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

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

评论

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