在mysql中的utf8mb4和utf8字符集有什么区别? [英] What is the difference between utf8mb4 and utf8 charsets in mysql?

查看:181
本文介绍了在mysql中的utf8mb4和utf8字符集有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

mysql中的 utf8mb4 utf8 字符集之间有什么区别?


我已经了解 ASCII,UTF-8,UTF-16 UTF-32 编码;
但是我很想知道'utf8mb4'组的编码与在mysql服务器中定义的其他编码类型的区别。



使用utf8mb4而不是utf8的任何特殊好处/建议?

解决方案

文档


名为utf8的字符集每个字符最多使用三个字节,并且只包含BMP字符。从MySQL 5.5.3开始,utf8mb4字符集每个字符最多使用四个字节支持补充字符:




  • BMP字符,utf8和utf8mb4具有相同的存储特性:相同的代码值,相同的编码,相同的长度。


  • 对于补充字符, utf8无法存储字符,而utf8mb4需要四个字节来存储它。由于utf8根本不能存储字符,因此您在utf8列中没有任何补充字符,并且在从旧版本的MySQL升级utf8数据时不必担心转换字符或丢失数据。



因此,它用于存储位于基本多语言平面,另请参见 Unicode编码比较


What is the difference between utf8mb4 and utf8 charsets in mysql?
I already know about ASCII, UTF-8, UTF-16 and UTF-32 encodings; but I'm curious to know whats the difference of 'utf8mb4' group of encodings with other encoding types defined in mysql server.

Are there any special benefits/proposes of using utf8mb4 rather than utf8?

解决方案

Documentation:

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 have identical storage characteristics: same code values, same encoding, same length.

  • For a supplementary character, utf8 cannot store the character at all, while utf8mb4 requires four bytes to store it. Since utf8 cannot store the character at all, you do not have any supplementary characters in utf8 columns and you need not worry about converting characters or losing data when upgrading utf8 data from older versions of MySQL.

So it's for storing characters lying outside the Basic Multilingual Plane, see also Comparison of Unicode encodings.

这篇关于在mysql中的utf8mb4和utf8字符集有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆