CnPack Forum


 
Subject: DELPHI或CNPACK有没有这样现成的函数?
wiseinfo
灌水科科长
Rank: 3Rank: 3



UID 560
Digest Posts 0
Credits 159
Posts 80
点点分 159
Reading Access 10
Registered 2004-11-11
Status Offline
Post at 2011-3-30 15:57  Profile | Blog | P.M. 
DELPHI或CNPACK有没有这样现成的函数?

类似DELPHI DFM文件中,ORD可以对单个处理, 想知道有没有现成的?

CHINA和谐中国    转换成右边的    'CHINA'#21644#35856#20013#22269

[ 本帖最后由 wiseinfo 于 2011-3-30 15:59 编辑 ]
Top
wiseinfo
灌水科科长
Rank: 3Rank: 3



UID 560
Digest Posts 0
Credits 159
Posts 80
点点分 159
Reading Access 10
Registered 2004-11-11
Status Offline
Post at 2011-3-30 16:26  Profile | Blog | P.M. 
从Classes.pas抄了一个

function StringConvert(S: string): string;
var
  L, I, J: Integer;
begin
  Result := EmptyStr;
  L := Length(S);
  if L = 0 then
    Exit;
  I := 1;

  repeat
    if (S[I] >= ' ') and (S[I] <> '''') and (Ord(S) <= 127) then
    begin
      J := I;
      repeat
        Inc(I)
      until (I > L) or (S[I] < ' ') or (S[I] = '''') or (Ord(S) > 127);
      Result := Result + '''';
      while J < I do
      begin
        Result := Result + string(AnsiChar(S[J]));
        Inc(J);
      end;
      Result := Result + '''';
    end
    else
    begin
      Result := Result + '#' + IntToStr(Ord(S[I]));
      Inc(I);
    end;
  until I > L;
end;
Top
 




All times are GMT++8, the time now is 2024-11-25 05:48

    本论坛支付平台由支付宝提供
携手打造安全诚信的交易社区 Powered by Discuz! 5.0.0  © 2001-2006 Comsenz Inc.
Processed in 0.007856 second(s), 7 queries , Gzip enabled

Clear Cookies - Contact Us - CnPack Website - Archiver - WAP