views:

185

answers:

2

hi, 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?

A: 

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.

Joey
+5  A: 

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.

Uwe Raabe
thank,this is what i needed.
avar