Every dayText & Encoding

ASCII & Unicode Value
calculator.

See the number behind every letter and symbol, or turn numbers back into text.

How it's worked out

Every character a computer stores is a number. ASCII is a 7-bit code, so it has 128 numbers, 0 to 127. It gives 72 to H, 105 to i and 32 to the space. The first 32 codes and code 127 are control codes, such as LF (line feed, 10), that steer a printer or a screen. They print no symbol, so the tool shows each one by its short name.

Unicode goes much further. It has 1,114,112 code points, written as U+ and a hex number, and its first 128 are the same as ASCII. So the code of a plain English letter is the same in both. A code point is the character's number; how that number is saved in a file is a separate step.

That step is usually UTF-8. It saves codes up to 127 as one byte, so ASCII text is unchanged. Larger codes take two, three or four bytes. Each byte starts with fixed marker bits that tell a reader how long the group is, and the rest of the bits carry the code point.

How many bytes UTF-8 uses (RFC 3629)
Code points (hex)BytesFirst byte starts
0 to 7F10
80 to 7FF2110
800 to FFFF31110
10000 to 10FFFF411110

Every byte after the first starts with 10. A code is the same number in any base: the tool shows it in decimal, hex, binary or octal, and the bits do not change.

Worked examples

Priya lists the codes in her name for a class exercise

Priya's class has to print the code of each character in "Hi Sam". The tool gives 72 105 32 83 97 109. The space counts as a character too: it is code 32, so her answer has 6 numbers, not 5.

Her teacher also asks for binary. The H is 01001000 and the i is 01101001. Each is 8 digits here, because a byte has 8 bits, but ASCII only ever uses the lower 7.

Open this example in the tool

Marco finds out why his menu shows the wrong letters

Marco types "Café" into his shop's website, and the page shows two odd symbols where the last letter should be. The tool shows 4 characters but 5 bytes in UTF-8. The é is U+00E9, code 233, outside ASCII, so it takes the bytes C3 A9.

The first byte is 110 then 00011, and the second is 10 then 101001. A program that reads each byte as one Latin-1 character shows 2 characters instead of one, starting with Ã. The fix is to tell that program the page is UTF-8, not to change the text.

Open this example in the tool

A puzzle hunt clue written in numbers

A clue card reads 68 105 103 105 116. Read as decimal codes, they spell "Digit". Every number is between 65 and 122, the span from A to z, which is a good sign that a list of numbers is ASCII text.

If the next card used hex, the same word would be 44 69 67 69 74. Set the base to hex, or write each code with 0x, and the tool reads them the same way.

Open this example in the tool

Reading your result

Characters and bytes can differ. For plain English text the two counts match. Once a character is outside ASCII they split: the euro sign is U+20AC, which takes 3 bytes. A database column sized in bytes can then hold fewer characters than you expect.

UTF-16 code units are a third count. JavaScript, Java and C# store text in 16-bit units. A code point above U+FFFF, such as the grinning face emoji at U+1F600, needs two of them, so one emoji has a length of 2 in those languages. The tool shows this count next to the character count.

The range tells you how a character behaves. Control codes print nothing. Codes 128 to 255 are where old 8-bit code pages disagree, which is why one byte can show as a different symbol on another system. Unicode keeps one meaning for every code, and its first 256 match Latin-1.

HTML references have limits. You can write any character in a web page as an ampersand, a hash, the code and a semicolon. The HTML standard does not allow this for most control codes or for carriage return, so the tool says when a reference would be refused.

Common mistakes

  • Reading the number 10 as one character. The text "10" is two characters, 49 and 48. The digit 0 is code 48, not 0; code 0 is the NUL control code, NUL.
  • Calling 128 to 255 ASCII. ASCII stops at 127. "Extended ASCII" means one of several code pages, so say which one, or use Unicode code points as this tool does.
  • Mixing up the code point and the bytes. U+00E9 is the number of é. C3 A9 is how UTF-8 saves it. Tools that take bytes and tools that take code points want different input.
  • Missing the line endings. A pasted line break is LF, code 10. Text from Windows files often ends lines with CR then LF, 13 then 10, which you will see as two codes.

Questions people ask

In Python, ord("A") gives 65 and chr(65) gives "A" back. In a Unix shell, printf "%d" "'a" prints 97. Use this page to check the answer, or to see the bytes your program writes once the text leaves ASCII.

Sources