## digitalmars.D.learn - ASCII code to char

• jicman (4/4) May 26 2007 Greetings!
• Derek Parnell (11/18) May 26 2007 If the value is truely ASCII then it is any number from zero to 127
• jicman (3/20) May 26 2007 Gosh... D is so easy... :-) Thanks Derek.
• janderson (6/28) May 26 2007 You should know, in C/C++ you could write:
jicman <cabrera_ _wrc.xerox.com> writes:
```Greetings!

say I have an integer value representing an ASCII character, how do I get that
character?  I was looking through Phobos, but there was no easy way of finding
it and I knew you guys could help me.

thanks,

josé
```
May 26 2007
Derek Parnell <derek psych.ward> writes:
```On Sat, 26 May 2007 13:54:36 -0400, jicman wrote:

Greetings!

say I have an integer value representing an ASCII character, how do I get that
character?  I was looking through Phobos, but there was no easy way of finding
it and I knew you guys could help me.

thanks,

If the value is truely ASCII then it is any number from zero to 127
inclusive. Values outside that range are not ASCII.

int val;
char c;

c = cast(char)val;

--
Derek Parnell
Melbourne, Australia
"Justice for David Hicks!"
skype: derek.j.parnell
```
May 26 2007
jicman <cabrera_ _wrc.xerox.com> writes:
```Derek Parnell Wrote:

On Sat, 26 May 2007 13:54:36 -0400, jicman wrote:

Greetings!

say I have an integer value representing an ASCII character, how do I get that
character?  I was looking through Phobos, but there was no easy way of finding
it and I knew you guys could help me.

thanks,

If the value is truely ASCII then it is any number from zero to 127
inclusive. Values outside that range are not ASCII.

int val;
char c;

c = cast(char)val;

Gosh... D is so easy... :-)  Thanks Derek.

jic
```
May 26 2007
janderson <askme me.com> writes:
```jicman wrote:
Derek Parnell Wrote:

On Sat, 26 May 2007 13:54:36 -0400, jicman wrote:

Greetings!

say I have an integer value representing an ASCII character, how do I get that
character?  I was looking through Phobos, but there was no easy way of finding
it and I knew you guys could help me.

thanks,

If the value is truely ASCII then it is any number from zero to 127
inclusive. Values outside that range are not ASCII.

int val;
char c;

c = cast(char)val;

Gosh... D is so easy... :-)  Thanks Derek.

jic

You should know, in C/C++ you could write:

int val;
char c;

c = (char)val;

I imagine however other languages may not be so "easy".
```
May 26 2007