Convert and Int32 value into a Character

  • Thread starter Thread starter Joshua Russell
  • Start date Start date
J

Joshua Russell

Hi,
Can anyone tell me how I can convert an Intager value such as '66' into the
letter 'f' (using ANSI ASCII).

Thanx Josh
 
Can anyone tell me how I can convert an Intager value such as '66' into the
letter 'f' (using ANSI ASCII).

Just cast it to char:

int i = 66;
char x = (char)i;

That will always give you the Unicode value. All ASCII characters have
the same value in Unicode.
 
Joshua

The integer value '66' is binary 01000010, or hex 0x42, which corresponds to
'B' in the ASCII character set. It will take a bit more than a simple cast
to make the conversion to ASCII 'f'...

However, this will work:

int ival = 0x66;
.. . .
char cval = (char)ival;
.. . .


regards
roy fine
 
Back
Top