How can I get the ascii character of a given ascii code.
e.g. I'm looking for a method that given the code 65 would return "A".
Thanks
The most basic and easy way to extract the character from an ASCII Code is to cast the ASCII code to a char directly; this will convert the asciiValue of the int type to a char type.
Try this: char c = 'a'; // or whatever your character is printf("%c %d", c, c); The %c is the format string for a single character, and %d for a digit/integer. By casting the char to an integer, you'll get the ascii value.
Using the chr () function, the character that represents the corresponding ASCII code can be obtained.
Do you mean "A" (a string
) or 'A' (a char
)?
int unicode = 65; char character = (char) unicode; string text = character.ToString();
Note that I've referred to Unicode rather than ASCII as that's C#'s native character encoding; essentially each char
is a UTF-16 code point.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With