先取出12,进行16进制运算,依次类推啦…… var str,Strsub:String; strR:String;//存放结果 i:integer; begin str:='1234'; strR:=''; strsub:=copy(str,1,2); Str:=Copy(Str,3,Length(Str)-2); while strsub<>'' do begin i:=strtoInt(Copy(strsub,1,1))*16+StrToInt(Copy(strsub,2,1)); StrR:=StrR+Chr(i); strsub:=copy(str,1,2); Str:=Copy(Str,3,Length(Str)-2); end; end;
我是这样写的,谢谢各位,我这就给分 function CompactData(strText : string) : string; var strR,strSrc,strSub:String; i:integer;begin strSrc:= strText; strR := ''; strSub := copy(strSrc,1,2); strSrc := Copy(strSrc,3,Length(strSrc)-2); while strSub <>'' do begin //get one char of the compact result data i:=StrToInt(Copy(strSub,1,1))*16+StrToInt(Copy(strSub,2,1)); strR:=strR+Chr(i); //get two char of the next source data strSub:=copy(strSrc,1,2); strSrc:=Copy(strSrc,3,Length(strSrc)-2); end; //result Result := strR; end;
Chr(StrToInt('$' + Copy(str, 1, 2)))
var
str,Strsub:String;
strR:String;//存放结果
i:integer;
begin
str:='1234';
strR:='';
strsub:=copy(str,1,2);
Str:=Copy(Str,3,Length(Str)-2);
while strsub<>'' do
begin
i:=strtoInt(Copy(strsub,1,1))*16+StrToInt(Copy(strsub,2,1));
StrR:=StrR+Chr(i);
strsub:=copy(str,1,2);
Str:=Copy(Str,3,Length(Str)-2);
end;
end;
有问题请发信息到我的E-mail:[email protected]
function CompactData(strText : string) : string;
var
strR,strSrc,strSub:String;
i:integer;begin
strSrc:= strText; strR := '';
strSub := copy(strSrc,1,2);
strSrc := Copy(strSrc,3,Length(strSrc)-2); while strSub <>'' do
begin
//get one char of the compact result data
i:=StrToInt(Copy(strSub,1,1))*16+StrToInt(Copy(strSub,2,1));
strR:=strR+Chr(i); //get two char of the next source data
strSub:=copy(strSrc,1,2);
strSrc:=Copy(strSrc,3,Length(strSrc)-2);
end; //result
Result := strR;
end;