In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
The main content of this article is to explain "what are the pits encountered in the specified coding of MySQL implementation?", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "what are the pits encountered in the specified coding of MySQL implementation?"
Write at the front
Environment: the MySQL5.7+,MySQL database character encoding is implemented as utf8, and the table is also utf8
Scenario: Wechat authorizes to obtain user information (including nicknames) and save it to the database. Some users succeed, but a few users fail.
So why did it fail?
Post an error log
Incorrect string value:'\ xF0\ x9F\ x98\ x98\ xF0\ x9F..' For column 'nickname' at row 1
It is caused by the emoji symbol in the Wechat nickname of the failed user.
Analysis:
MySQL supports multiple character coding sets, such as UTF-8, GB2312, GBK, etc.
You can view it through the SHOW CHARSET command.
Usually we recommend using UTF-8 as the default character encoding.
As we can see from the figure above, the MySQL database has two UTF-8 coding implementations.
Utf8:utf8 encoding only supports less than three bytes. In utf8 coding, Chinese accounts for 3 bytes, while other English, numbers and symbols account for 1 byte. But emoji symbols account for 4 bytes, and some more complex text and traditional characters also account for 4 bytes.
The complete implementation of utf8mb4:UTF-8 coding. It supports up to 4 bytes, so it can be used to store emoji symbols.
Referring to the information, the official explanation is:
Last
Tips: if you have a field that needs to save the emoji symbol, be sure to specify the encoding as utf8mb4.
At this point, I believe you have a deeper understanding of "what are the pits encountered in the specified coding for the implementation of MySQL?" you might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.