请问如何把 hex 转换成字符(100分)

  • 主题发起人 主题发起人 leo.1999
  • 开始时间 开始时间
L

leo.1999

Unregistered / Unconfirmed
GUEST, unregistred user!
请问大家,如何把内存数据:<br>BB C6 BA D7 C2 A5<br>转换成文字呢?<br>比如<br>BB C6 BA D7 C2 A5=黄鹤楼<br>这样转换!<br>谢谢!!!!!!!!!!!!!!
 
你可以把16进制转化为unicode啊,知道了unicode不就知道他对应的汉字了吗<br>作为中间转换我给你提供一个函数,供参考:<br>function HEXtoASCII(hexint:longint):string;<br>var<br>&nbsp; str:string;<br>&nbsp; &nbsp; j:integer;<br>begin<br>&nbsp; str:='';<br>&nbsp; &nbsp; j:=0;<br>&nbsp; repeat<br>&nbsp; &nbsp; str:=str+char((hexint shr(j*8))mod 256);<br>&nbsp; &nbsp; hexint:=hexint div 256;<br>&nbsp; until &nbsp;hexint:=0;<br>&nbsp; result:=str;<br>end;<br>
 
大哥``给点全面的吧``我菜```<br>分不够可以加的嘛``
 
方式一:<br>procedure TForm1.FormClick(Sender: TObject);<br>var<br>s:string;<br>begin<br>s:=chr($bb)+chr($c6)+chr($ba)+chr($d7)+chr($c2)+chr($a5);<br>showmessage(s);<br><br>end;<br><br>方式二<br>function HEXtoASCII(hexint:longint):string;<br>var<br>&nbsp;str:string;<br>&nbsp; &nbsp;j:integer;<br>begin<br>&nbsp;str:='';<br>&nbsp; &nbsp;j:=0;<br>&nbsp;repeat<br>&nbsp; &nbsp;str:=str+char((hexint shr(j*8))mod 256);<br>&nbsp; &nbsp;hexint:=hexint div 256;<br>&nbsp;until &nbsp;hexint=0; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //不是hexint:=0<br>&nbsp;result:=str;<br>end;<br><br>procedure TForm1.FormClick(Sender: TObject);<br>var<br>s:string;<br>begin<br><br>s:=hextoascii($C6BB)+hextoascii($d7ba)+hextoascii($a5c2);<br>showmessage(s);<br><br>end;
 
先谢谢大家了`但我所要得到的HEX 首先就是未知的``那么我要怎么做呢?
 
定义字节byte或word(longint)类型数据,然后赋予你所说的未知的hex值,在放入chr()或HEXtoASCII()转化成字符或字符串即可
 
接受答案了.
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
551
import
I
I
回复
0
查看
743
import
I
I
回复
0
查看
665
import
I
后退
顶部