Home > Database > Mysql Tutorial > emoji表情无法插入MySQL中_MySQL

emoji表情无法插入MySQL中_MySQL

WBOY
Release: 2016-05-31 08:50:11
Original
1214 people have browsed it

        IOS端的数据通过PHP透传到后台C++,上PHP系统会自动把Unicode转码成UTF-8。
        UTF-8编码的emoji表情无法插入MySQL中。

        经过分析发现,emoji表情是Unicode6.1才引入的,转成UTF-8为四个字节的编码方式,而不是像汉字,UTF-8编码为3个字节。而MySQL中如果对longext字段存储时选择存储方式为UTF-8是无法处理四字节的UTF-8编码,只有utf8mb4的编码方式才支持4字节的UTF-8编码。所以选择utf8mb4的编码方式,mysql才能存储4字节的UTF-8编码,从而存储emoji表情。而且MySQL需要升级到5.5的版本。

        但是存储到MySql的编码虽然后壳存储4字节的UTF-8编码,但是无法成功显示,因为存进去的是乱码。所以需要把UTF-8转成Unicode再存入MySQL。

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template