function HexToStr(mHex: string): string;
var
I: Integer;
begin
for I := 1 to Length(mHex) div 2 do
Result := Result + Chr(StrToIntDef('$' + mHex[I * 2 - 1] + mHex[I * 2], 0));
end; { HexToStr }function StrToHex(mStr: string): string;
var
I: Integer;
begin
Result := '';
for I := 1 to Length(mStr) do
Result := Format('%s%.2x', [Result, Ord(mStr[I])]);
end; { StrToHex }
var
I: Integer;
begin
for I := 1 to Length(mHex) div 2 do
Result := Result + Chr(StrToIntDef('$' + mHex[I * 2 - 1] + mHex[I * 2], 0));
end; { HexToStr }function StrToHex(mStr: string): string;
var
I: Integer;
begin
Result := '';
for I := 1 to Length(mStr) do
Result := Format('%s%.2x', [Result, Ord(mStr[I])]);
end; { StrToHex }
解决方案 »
- 把文件上传到指定的服务器文件夹,但客户端不能打开服务器文件夹
- (保证结贴给分)面临痛苦选择:用 c# 还是 delphi 开发桌面应用程序?
- 请教一com口的问题.谢谢
- 怎么把Timage里的图片,放大或缩小成指定横纵大小的图片,如:设成宽160,高355的图片?
- (请问在表里添加数据时如果有的话就不加跳过去应怎么办好点)在线等待解决马上结帖
- ado的大 部分连接字符串的写法(来自codeproject)http://www.codeproject.com/database/connectionstrings.asp
- 关于TreeView的问题!
- sunnf接分,原因见里面url
- dbgrig里面的数据怎么样做连接啊?
- 小弟决定自己坐一个图书管理系统,就几个简单的模块,大家有什么建议没有呀?提得好有分呀!
- 什么防火墙比较好????
- 数据库是SQL server,有个表的字段是numeric型,小数位数15位,通过ADOTable连接,但输入有10位数字后,保存、显示只有4位小数,何解?
var
I: Integer;
begin
Result := ''; //赋一个初值安全点
for I := 1 to Length(mHex) div 2 do
Result := Result + Chr(StrToIntDef('$' + mHex[I * 2 - 1] + mHex[I * 2], 0));
end; { HexToStr }
var
I: Integer;
begin
Result := '';
for I := 1 to Length(mStr) do
Result := Format('%s%%%.2x', [Result, Ord(mStr[I])]); //%%->%
end; { StrToHex }
http://kingron.myetang.com/zsfunc0q.htm
//请参考function StringToDisplay(mString: string): string;
var
I: Integer;
S: string;
begin
Result := '';
S := '';
for I := 1 to Length(mString) do
if mString[I] in [#32..#127] then
S := S + mString[I]
else begin
if S <> '' then begin
Result := Result + QuotedStr(S);
S := '';
end;
Result := Result + Format('#$%x', [Ord(mString[I])]);
end;
if S <> '' then Result := Result + QuotedStr(S);
end; { StringToDisplay }function DisplayToString(mDisplay: string): string;
var
I: Integer;
S: string;
B: Boolean;
begin
Result := '';
B := False;
mDisplay := mDisplay;
for I := 1 to Length(mDisplay) do
if B then case mDisplay[I] of
'''': begin
if S <> '' then Result := Result + StringReplace(S, '''''', '''', [rfReplaceAll]);
if Copy(mDisplay, I + 1, 1) = '''' then Result := Result + '''';
S := '';
B := False;
end;
else S := S + mDisplay[I];
end
else case mDisplay[I] of
'#', '''': begin
if S <> '' then Result := Result + Chr(StrToIntDef(S, 0));
S := '';
B := mDisplay[I] = '''';
end;
'$', '0'..'9', 'a'..'f', 'A'..'F': S := S + mDisplay[I];
end;
if (not B) and (S <> '') then Result := Result + Chr(StrToIntDef(S, 0));
end; { DisplayToString }
//字符串转换为十六进制字符串:例如‘ABCD’->‘41424344’*************************
//==============================================================================
function BinaryToHexStr(Str:string):string;
var i: integer;
begin
Result := '';
for i:=1 to Length(Str) do Result := Result + IntToHex(Ord(Str[i]),2);
end;//==============================================================================
//十六进制字符串转换为字符串:例如‘41424344’->‘ABCD’*************************
//==============================================================================
function HexStrToBinary(Str:string):string;
var i, Len: integer;
Point: Pointer;
begin
Len := Length(Str) div 2;
Point := AllocMem(Len + 1);//Len + 1是为nil结尾的标志空出一个字节
Pointer(Result) := Point;
for i:=0 to Len do Result[i]:= Chr(StrToint('$' + Copy(Str, i*2-1, 2)));
ReallocMem(Point, Len + 1);
end;