本文整理自网络,侵删。
function TForm1.myStrToHex(s:string):string; //字串转16进制var TmpStr:string; i:integer;begin TmpStr:=''; for i:=1 to Length(s)do begin TmpStr:=TmpStr+IntToHex(ord(s[i]),2); end; Result:=TmpStr;end;
function TForm1.myHexToStr(s:string):string; //16进制转字串var HexS,TmpStr:string; i:Integer; a:Byte;begin HexS:=s; if Length(HexS) mod 2=1 then begin HexS:=HexS+'0'; end; TmpStr:=''; for i:=1 to(Length(HexS)div 2)do begin a:=StrToInt('$'+HexS[2*i-1]+HexS[2*i]); TmpStr:=TmpStr+Chr(a); end; Result:=TmpStr;end;
摘抄自http://blog.csdn.net/chinazhd/article/details/7578412
相关阅读 >>
Delphi 查看字符串在不同编码(ascii、unicode、utf7、utf8、default、bigendianunicode)下的 hex
Delphi 资源文件管理 resources and images
更多相关阅读请进入《Delphi》频道 >>