Replacement character

The replacement character (often a black diamond with a white question mark) is a symbol found in the Unicode standard at codepoint U+FFFD in the Specials table. It is used to indicate problems when a system is not able to render a stream of data to a correct symbol. It is most commonly seen when a font does not contain a character, but is also seen when the data is invalid and does not match any character:

Consider a text file containing the German word "für" in the ISO-8859-1 encoding. This file is now opened with a text editor that assumes the input is UTF-8. The first and last byte are valid UTF-8 encodings of ASCII, but the middle byte is not a valid byte in UTF-8. Therefore a text editor could replace this byte with the replacement character symbol to produce a valid string of Unicode code points. The whole string now displays like this: "".

A poorly implemented text editor might save the replacement in UTF-8 form; the text file data will then look like this:, which will be displayed in ISO-8859-1 as "fï¿½r" (see mojibake). Since the replacement is the same for all errors this makes it impossible to recover what character was intended. A better (but harder to implement) design is to preserve the original bytes, including the error, and only convert to the replacement when displaying the text. This will allow the text editor to save the original byte sequence, while still showing the error indicator to the user.

It has become increasingly common for software to interpret invalid UTF-8 by guessing the bytes are in another byte-based encoding such as ISO-8859-1. This allows correct display of both valid and invalid UTF-8 pasted together. If a web page uses ISO-8859-1 (or Windows-1252) but specifies the encoding as UTF-8, most web browsers used to display all umlauts, ß's, and accented characters as, but newer browsers now translate the erroneous bytes individually to characters in Windows-1252, so the replacement character is less frequently seen.