如何显示十六进制代码字符?
我有一个文件,每一行都包含 FB8E、FB8F、FB90 等数字。
我希望在我的程序中加载此文件并获取每一行并打印与该数字/行对应的字符。
例如,我的第一行是 FB8E,我想要一些东西来转换它,例如 #$FB8E(阿拉伯语 Kaf),我该怎么做?
i have a file contains numbers like FB8E,FB8F,FB90 on each line.
i want in my program to load this file and take each line and print the character corresponded to that number/line.
for expamle, my firnst line is FB8E, i want something to convert it like #$FB8E (arabic Kaf), how do i do that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您在 D2009/2010:
否则将 Char 替换为 WideChar。
当然,代码可以稍微压缩一下,但为了清楚起见,我省略了这一点。
编辑:对于那些不害怕类型转换的人来说,classes.pas 中还有 HexToBin 函数。
If you are in D2009/2010:
otherwise replace Char with WideChar.
Of course the code can be compressed a little bit, but I left this out for clarity.
EDIT: For those of you being not afraid of type casting there is also the HexToBin function in classes.pas.
您不会对简单地将行转换为
#$FB8E
感到满意,因为编译器很可能会为您解决这些问题。因此,这里的一般方法是读取该行,解析十六进制值并根据该值创建一个 WideChar。但近年来我没有做太多 Delphi,所以我恐怕无法告诉你具体如何做到这一点。
You won't be too happy with simply converting the line to
#$FB8E
as the compiler most likely sorts these out for you.So the general approach here would be to read the line, parse the hex value and create a WideChar from that value. But I didn't do much Delphi in recent years so I'm afraid I can't tell you exactly how to do this.