Binary → text with a corrupted byte — binary and text

edge casewhat to do with input that cannot decode

Answer

1 invalid byte(s) flagged, not silently replaced

Why this example is worth doing

A bit string that is not valid UTF-8, which the tool reports as invalid at a specific byte offset rather than substituting a replacement character and pretending it worked. The page explains what makes a sequence invalid — a continuation byte without a leader, or a leader promising more bytes than are present — and this is deliberately the one example on the page with no clean answer, because the diagnostic is the answer.

Try your own input in the Binary ⇄ text / ASCII. Convert text to binary and back, byte by byte, with the full UTF-8 breakdown.

How the answer is reached

Decode 2 bytes as UTF-8

Decode 2 bytes as UTF-8 — columns byte, binary, hex, decimal
bytebinaryhexdecimal
011000011C3195
1001010012941
Decode 2 bytes as UTF-8 — columns code point, character
code pointcharacter
U+FFFD
U+0029)

text�)

Warning:

1 invalid sequence replaced with U+FFFD, at byte offset 0. In fatal mode this input would be rejected instead.

Source: RFC 3629; WHATWG Encoding Standard

Compare with

Open this example in the Binary ⇄ text / ASCII

The field arrives filled in with this example’s input.

Note:

Notation this page assumes

  • Bit strings are written most significant bit first, and bit 0 is the least significant bit.
  • A width is stated explicitly wherever it changes the answer; nothing is silently sign-extended or truncated.
  • ASCII is the 7-bit set padded to one byte; UTF-8 is shown byte by byte, so a non-ASCII character is more than eight bits.

Sources

  • ANSI X3.4 / ISO-IEC 646, the ASCII character set
  • The Unicode Standard, Annex on the UTF-8 encoding form