简体   繁体   中英

Saving Emojis in CKEditor (Emojione) in DB

I have "Empjione" ( https://github.com/braune-digital/ckeditor-emojione ) as an add-on in a CKEditor 4 installation. However, most of the emojis don't get saved to the DB (some do though). I'm saving the output of the CKEditor as HTML into the DB.

Here are a few that do get saved: ❤️, ☝️, ⚠️
Here are a few that don't get saved: 👨, 💨, 👽

For example, this: some text 💀 now more text Ends up as this in my DB: <p>some text&nbsp;

Any thoughts? Or is there a better emoji add-on that anyone knows of?

This has nothing to do with CKEditor but rather MySQL. Your data is likely using utf8 . MySQL's utf8 actually only allows three bytes per character; the emojis that use 4 bytes aren't saving. If you were running MySQL in strict mode it would give you an Incorrect string value error.

You can fix this by changing your database's character set to utf8mb4 .

This DBA Stack Exchange post explains how to do this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM