Function
StrToHexStr(
Const
S:
String
):
String
;
Var
I:
Integer
;
Begin
For
I :=
1
To
Length(S)
Do
Begin
If
I =
1
Then
Result := IntToHex(Ord(S[
1
]),
2
)
Else
Result := Result +
' '
+ IntToHex(Ord(S[I]),
2
);
End
;
End
;
function
strToHexStr(str:
string
):
string
;
var
c:
char
;
ss:
string
;
begin
while
str<>
''
do
begin
c:=str[
1
];
ss:=ss+format(
'%0x'
,[ord(c)]);
delete(str,
1
,
1
);
end
;
strtohexStr:= ss;
end
;
Function
HexStrToStr(
Const
S:
String
):
String
;
Var
t:
Integer
;
ts:
String
;
M, Code:
Integer
;
Begin
t :=
1
;
Result :=
''
;
While
t <= Length(S)
Do
Begin
While
(t <= Length(S))
And
(
Not
(S[t]
In
[
'0'
..
'9'
,
'A'
..
'F'
,
'a'
..
'f'
]))
Do
Inc(t);
If
(t +
1
> Length(S))
Or
(
Not
(S[t +
1
]
In
[
'0'
..
'9'
,
'A'
..
'F'
,
'a'
..
'f'
]))
Then
ts :=
'$'
+ S[t]
Else
ts :=
'$'
+ S[t] + S[t +
1
];
Val
(ts, M, Code);
If
Code =
0
Then
Result := Result + Chr(M);
Inc(t,
2
);
End
;
End
;
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步