Delphi 极速字符串替换函数字符串转16进制


本文整理自网络,侵删。

 //字符串转16进制
function StrToHex(src:string): string;
var
  i: integer;
  des: string;
begin
   des := '';
   for i := 1 to Length(src) do
   begin
     des := des + IntToHex(Ord(src[i]),2) + ' ';
   end;
   Result := des;

end;

 

字符串转16进制,其它平台结果相同

//经测试,以下代码任意平台测试结果相同

function StrToHex2(AStr: string): string;

var

 Idx: Cardinal;

begin

  Result:='';

  for Idx := Low(AStr)to High(AStr)do begin

    Result:= Result + IntToHex(Ord(AStr[Idx]), 4);

  end;

end;

// 调用

procedure TForm1.Button1Click(Sender: TObject);

begin

  Showmessage(StrToHex2('你好中国'));

end;

相关阅读 >>

Delphi httpserver 使用方法

Delphi xe2获取文件的 md5、crc、sha-1、sha-256、sha-512

Delphi跨平台tcp库的封装

Delphi 使窗口透明,并透过透明的窗口操作下面的窗口

Delphi 读cpu串号的代码

Delphi base64加解密

Delphi 修改exe应用程序图标

Delphi实现双击左ctrl键调用记事本

Delphi 单击android上的web浏览器链接以启动Delphi应用程序

Delphi 十进制转十六进制

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



打赏

取消

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

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

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

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

评论

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