zoukankan      html  css  js  c++  java
  • Delphi 处理在字符串截取中避免出现半个汉字

    2007年12月7日//..处理中英文混杂左截取
    function LeftStrEx(const AText: string; ACount: Integer): string;
    var
      I,ChrLen,
      BreakLen:Integer;
      IsMBCS:Boolean;
    begin
       I := 1;
       BreakLen := 0;
       IsMBCS := False;
       if Length(AText)>ACount then
       begin
          while I<=ACount do
          begin
             if AText[I] in LeadBytes then
             begin
                ChrLen := CharLength(AText,I)-1;
                I:= I + ChrLen;
                //说明AText[ACount]不是一个中文字符的末尾
                if I>ACount then
                begin
                   IsMBCS := True;
                   BreakLen := I - ChrLen - 1;
                   Break;
                end;
             end;
             //..
             Inc(I);
          end;
       end;
       //AText[ACount]不是半个中文字符
       if not IsMBCS then
          Result := LeftStr(AText,ACount)
       else
          Result := LeftStr(AText,BreakLen);
    end;

  • 相关阅读:
    为什么要写技术博客?
    MySQL开发总结
    如何在Linux实现自动运行程序
    SSH无密码登录
    PHP版本MS17-010检测小脚本
    Msf的一些常用操作
    bypass safedog upload
    mysql拿webshell总结
    web端MSF搭建
    【漏洞复现】Tomcat CVE-2017-12615 远程代码执行漏洞
  • 原文地址:https://www.cnblogs.com/pilybird/p/986711.html
Copyright © 2011-2022 走看看