The difference between MySQL UTF8 and utf8mb4

Source: Internet
Author: User

Utf-8 time-varying length encoding, storing a code point requires 1~4 bytes.

However, MySQL UTF8 only stores a maximum of 3 bytes per code point.

Therefore, the UTF8 character set cannot store all Unicode code points.

Only from 0x000 to 0xFFFF (called Basic multilingual Plane:bmp)

The character set named UTF8 uses a maximum of three bytes per character and contains only BMP characters. As of MySQL 5.5.3, the UTF8MB4 character set uses a maximum of four bytes per character supports supplemental characters:

    • For a BMP character, UTF8 and utf8mb4 with identical storage characteristics:same code values, same encoding, same length .

    • For a supplementary character, UTF8 cannot store the characterat all, while UTF8MB4 requires four bytes to store It. Since UTF8 cannot store the character at all, don't have any supplementary characters in UTF8 columns and you need no T worry about converting characters or losing data when upgrading UTF8 data from older versions of MySQL.

So if you want your column to support storing characters lying outside the BMP (and you usually want to), such as emoji, u Se "UTF8MB4". See also what is the most common non-bmp Unicode characters on actual use?.

The difference between MySQL UTF8 and utf8mb4

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.