Why is my page in a bad shape?
The disorder is one of the most troubling problems in Web development. It usually happens. Wrong decoding scheme used to read bytes 。 To solve the mess, we must understand. Unicode and UTF-8 Relationship.
🚨 scene 1: the database is stored in normal form and read as "?" or "cooking"
Reason analysis: The "cracker" is caused by the wrong GBK decoded character for UTF-8 and then the UTF-8 back. This tool allows you to enter the original text and see it in the real hexadecimal byte under UTF-8. If the bytes in the database do not match this, indicate in Writing Phase There has been a coding error.
🚨 scene 2: Emoji expression leads to error or interruption of backend
Reason analysis: The traditional MySQL `utf8 ' encoding can only store up to 3 byte characters, but emoji like 🌍 (U+1F30D) 4 bytes required under UTF-8. Use this tool to analyze Emoji, you'll find its UTF-8 sequence is 4 Group hexadecimal. This reminds you of the need to change the database code to `utf8mb4 ' .
Core terminology
- Unicode : a set of criteria that assigns a single number (known as " code points " , such as U+4E2D) to almost all characters in the world.
- UTF-8 : A longer code is achieved. It uses 1 to 4 A byte is a code point. It is currently the most common code on the Internet.
- UTF-16 : Codes used inside JavaScript engine. Normal characters are 2 bytes, special characters (e. g. Emoji) are 4 bytes (agent pair).
How can this tool be debugged?
- Enter the character you suspect is in the above box.
- See its **UTF-8 hexadecimal** sequence in the table below.
- Finds inconsistencies in your backend log, database raw binary data or hexadecimals in the result of the grab package.