How to convert ASCII code 0-255 to its corresponding character?
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
The first thing to fix in this question is terminology: ASCII is only 7-bit and officially covers values 0 through 127. Values 128 through 255 are not standard ASCII. They belong to some 8-bit encoding or raw byte interpretation, and the actual character depends on which code page or encoding you mean.
Distinguish ASCII from 8-Bit Encodings
For true ASCII:
- '
0through31are control codes' - '
32through126are printable characters' - '
127isDEL'
If you ask for 65, the answer is reliably A in ASCII. But if you ask for 200, there is no universal ASCII answer because ASCII does not define that value.
That is why people often get inconsistent results when they treat 0-255 as one fixed character table. The upper half depends on encodings such as Latin-1, Windows-1252, or something else entirely.
Convert Numeric Codes in Python
In Python, chr() converts a Unicode code point, not specifically an ASCII byte. For the ASCII range, that is still fine.
If you need byte-to-text decoding for values 128-255, use an explicit encoding.
Those two decodes can produce different visible characters for the same byte value depending on the encoding chosen.
Convert Numeric Codes in C and C++
In C or C++, a numeric byte can be cast to char, but printing it still depends on the execution character set and terminal encoding.
For the standard ASCII range, this is predictable. For higher values, the output depends on the environment. That is why byte-oriented code should usually think in terms of encodings, not vague "ASCII 0-255" language.
JavaScript and the Encoding Question
JavaScript provides character helpers too, but again, these are Unicode-oriented.
If you are interpreting bytes from a file or network payload, the correct approach is usually to decode the bytes with the right encoding rather than assuming a direct ASCII table.
Control Codes Are Real Characters, but Not Printable Ones
Values such as 0, 9, 10, and 13 are not printable letters or symbols. They represent control behavior such as null, tab, line feed, and carriage return.
Using repr is a good debugging trick because it shows escape-style representations for non-printable characters.
This matters when you think a conversion failed but the code actually produced a valid control character that simply does not render visibly.
If You Need a Stable 0-255 Mapping, Name the Encoding
If the requirement is "given a byte value from 0 to 255, show the corresponding character," then the correct answer must include the encoding name.
For example, Latin-1 is a simple one-byte mapping for the full 0-255 range.
Latin-1 gives a deterministic result for every byte. Windows-1252 gives a different deterministic result for some of the upper values. Without naming the encoding, the question is underspecified.
Common Pitfalls
- Calling values
128-255ASCII when standard ASCII only defines0-127. - Assuming every numeric byte maps to the same character in every encoding.
- Printing control codes and expecting visible output instead of non-printable behavior.
- Using Unicode conversion helpers when the real problem is byte decoding.
- Forgetting that terminal and runtime encoding settings affect how high-byte values appear.
Summary
- Standard ASCII covers only values
0-127. - Values
128-255need an explicit 8-bit encoding such as Latin-1 or Windows-1252. - Use language helpers such as
chrorString.fromCharCodecarefully and know whether they operate on Unicode code points or bytes. - Control codes convert correctly even though they are not printable.
- If you want a reliable byte-to-character result for the full
0-255range, always name the encoding.

