字符转换十六进制

来源:互联网 发布:小米5移动数据连不上 编辑:程序博客网 时间:2024/06/06 15:18

function StrToHex(Value: string): string;
var
  i,total: integer;
begin
  total :
= 0;
 
for i := 1 to Length(Value) do
 
begin
    total :
= total + Ord(Value[i]);
 
end;
  Result :
= Format('%x',[total]);
 
if Value = '' then Result := '00';
 
if Length(Result) = 1 then
    Result :
= Result+'0';
end;

 

 

2.

var
  str: string;
begin
  str:= '$'+inttohex(ord('1'),2);