Interactive UTF-8 Decoder Demo

This decoder is part of my series on decoding UTF-8

To help illustrate my explanation, I've written an interactive decoder below. First, enter in a series of bytes in hexadecimal. Then, press the "Decode" button. The resulting output (or error) will be displayed in the output box. For example, entering "F2 80 9F A2" will result in the byte sequence <0xF2 0x80 0x9F 0xA2>. When decoded, it should result in U+807E2.

Output:
Press "Decode" to view output
Some Example Inputs and Outputs
  • 41U+41
  • ED 9F 80U+D7C0
  • F4 80 80 8FU+10000F
  • ED BF 80UTF8 Decode Error: Decoded surrogate near byte 4
  • C1 81UTF8 Decode Error: Overlong near byte 3
  • 41 42 80UTF8 Decode Error: Invalid code unit at byte 4

Decoder Demo Source