简体   繁体   English

在数据库的CKEditor(Emojione)中保存表情符号

[英]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. 我将“ Empjione”( https://github.com/braune-digital/ckeditor-emojione )作为CKEditor 4安装中的附件。 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. 我将CKEditor的输出作为HTML保存到数据库中。

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; 例如,以下内容: some text 💀 now more text最终在我的数据库中这样显示: <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. 这与CKEditor无关,而与MySQL无关。 Your data is likely using utf8 . 您的数据可能使用utf8 MySQL's utf8 actually only allows three bytes per character; MySQL的utf8实际上每个字符只允许三个字节。 the emojis that use 4 bytes aren't saving. 使用4个字节的表情符号不会保存。 If you were running MySQL in strict mode it would give you an Incorrect string value error. 如果您在严格模式下运行MySQL,则会给您一个Incorrect string value错误。

You can fix this by changing your database's character set to utf8mb4 . 您可以通过将数据库的字符集更改为utf8mb4来解决此utf8mb4

This DBA Stack Exchange post explains how to do this. 此DBA Stack Exchange帖子介绍了如何执行此操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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