In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
1. The situation of the problem
In the development of IM, some useful avatars use emoji emoticons or chat emoticons using emoji emoticons, but the mysql database uses utf8_general_ci, that is, utf-8 coding, and the result is an error. Emoji emoticons cannot be saved in the database.
Java.sql.SQLException: Incorrect string value:'\ xF0\ x9F\ x92\ xAA ",... 'for column' raw_json' at row 1
2. Why is there such a reason
Because mysql's utf8 encodes up to 3 bytes of a character, but an emoji emoji is 4 bytes, utf8 does not support storing emoji emoticons. But utf8's superset utf8mb4 can have up to 4 bytes in a character, so it can support the storage of emoji emoticons.
3. Solution
Scheme 1: modify the code set of the database to utf8mb4, whether it is a database or a table or a field. Although it will increase storage, this is negligible.
Solution 2: sometimes you can not modify the database coding and so on, you can use java to transform and encode emoji expressions, such as emoji-java, which has a special treatment for emoji expressions, and then save or remove expressions, which is also a compromise solution.
Download address of emoji-java: https://github.com/vdurmont/emoji-java
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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.