Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is exactly an overlong form/encoding?

Reading the Wikipedia article on UTF-8, I've been wondering about the term overlong. This term is used various times but the article doesn't provide a definition or reference for its meaning.

I would like to know if someone can explain the term and its purpose.

like image 262
nEAnnam Avatar asked Aug 18 '11 19:08

nEAnnam


People also ask

Is UTF-8 the same as Unicode?

The Difference Between Unicode and UTF-8Unicode is a character set. UTF-8 is encoding. Unicode is a list of characters with unique decimal numbers (code points).

What is a Unicode character example?

The code point is a unique number for a character or some symbol such as an accent mark or ligature. Unicode supports more than a million code points, which are written with a "U" followed by a plus sign and the number in hex; for example, the word "Hello" is written U+0048 U+0065 U+006C U+006C U+006F (see hex chart).

What UTF-8 means?

UTF-8 (UCS Transformation Format 8) is the World Wide Web's most common character encoding. Each character is represented by one to four bytes. UTF-8 is backward-compatible with ASCII and can represent any standard Unicode character.

What are the most common character encodings formats?

The most common encoding schemes are : UTF-8. UTF-16. UTF-32.


2 Answers

It's an encoding of a code point which takes more code units than it needs to.

For example, U+0020 is represented in UTF-8 by the single byte 0x20. If you decode the two bytes 0xc0 0xa0 in the normal fashion, you'll still end up back at U+0020, but that's an invalid representation.

The Unicode Corrigendum #1 has more information, particularly around table 3.1B.

like image 108
Jon Skeet Avatar answered Oct 10 '22 21:10

Jon Skeet


UTF-8 theoretically allows for different representations of characters that also have a shorter one. For example, you could encode an ASCII character in two bytes by setting the MSBs to zero. The UTF-8 specification explicitly forbids this.

like image 34
Joey Avatar answered Oct 10 '22 20:10

Joey