3 ms·
ctrl+f doesn't show mention of utf8mb4 except in comments. In short: you should only use utf8mb4 in mysql as charset, cause utf8 in mysql is a broken invented
by riffraff 12y ago
ctrl+f doesn't show mention of utf8mb4 except in comments.
In short: you should only use utf8mb4 in mysql as charset, cause utf8 in mysql is a broken invented 3-byte charset that will explode when you input 4-byte characters (i.e. an emoji).
utf8mb4 is what the rest of the world actually calls utf8.
- dspillett 12y agoThat was added in 5.5 IIRC, which wasn't released until the end of 2010 - so if would be understandable if the writer of this article did not have know about it back in mid 2009, or knew about it (if it was a much talked about plan the a release that was happening "soon") but chose to ignore it in favour of concentrating on what is available for production systems.
- riffraff 12y agothanks, I didn't mean to fault the author, I was just trying to be helpful to the casual readers.
- masklinn 12y agoHere's a document on utf8 v utf8mb4, how to migrate from one to the other, and the potential pitfalls involved (due to utf8 being stored as fixed-size 3 bytes and utf8mb4 being stored as fixed-size 4 bytes): https://mathiasbynens.be/notes/mysql-utf8mb4 https://mathiasbynens.be/notes/mysql-utf8mb4
- morgo 12y agoTo clarify: the 3-byte subset is not a MySQL invention. It is the Basic Multilingual Plane (BMP): http://en.wikipedia.org/wiki/Plane_%28Unicode%29#Basic_Multilingual_Plane http://en.wikipedia.org/wiki/Plane_%28Unicode%29#Basic_Multi...
- Zr40 12y agoThat's not correct. The Basic Multilingual Plane (like Unicode itself) is not an encoding, it is a subset of the Unicode codespace. UTF-8 restricted to sequences of 3 bytes can only represent characters between U+0000 and U+FFFF inclusive, which happens to exactly contain the characters defined by the BMP.
- sly010 12y agoMost smileys now ubiquitous on smart phone keyboards are valid Unicode characters outside of the BMP set, yet being used constantly on the web. BMP just doesn't make sense anymore, nor does mysql utf8.
- morgo 12y agoI totally agree! It also makes sense for countries that have their own character sets to use utf8 too (as they may borrow words, characters from other languages). I was just pointing out that even if it was limited support, it wasn't a set of characters that MySQL came up with.
- deleted 12y ago[deleted]
- imron 12y agoMySQL's 3-byte 'utf8' is the reason I first switched to PostgreSQL. I never looked back.
- deleted 12y ago[deleted]