English 中文(简体)
how to show hex code char?
原标题:

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?

最佳回答

If you are in D2009/2010:

var
  F: TextFile;
  Line: string;
  Code: Integer;
  Ch: Char;

...
Readln(F, Line);
Code := StrToInt( $  + Line);
Ch := Char(Code);
...

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.

问题回答

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.





相关问题
determining the character set to use

my delphi 2009 app has a basic translation system that uses GNUGetText. i had used some win API calls to prepare the fonts. i thought it was working correctly until recently when someone from Malta ...

Help with strange Delphi 5 IDE problems

Ok, I m going nuts here. For the last (almost) four years, I ve been putting up with some extremely bad behavior from my Delphi 5 IDE. Problems include: Seemingly random errors in coride50.bpl ...

How to write a Remote DataModule to run on a linux server?

i would like to know if there are any solution to do this. Does anyone? The big picture: I want to access data over the web, using my delphi thin clients. But i´would like to keep my server/service ...

How convert string to integer in Oxygene

In Delphi, there is a function StrToInt() that converts a string to an integer value; there is also IntToStr(), which does the reverse. These functions doesn t appear to be part of Oxygene, and I can ...

Quick padding of a string in Delphi

I was trying to speed up a certain routine in an application, and my profiler, AQTime, identified one method in particular as a bottleneck. The method has been with us for years, and is part of a "...

热门标签