UTF-8 issues with tinymce?

与世无争的帅哥 提交于 2019-12-13 02:35:13

问题


I am experiencing some issues with curly quotes and apostrophes when pasting from a word document into tincymce hmtl editor, for some reason it converts these characters into Â, ’ etc.

Things I have checked:

Firstly I have ensured all the html pages all have the correct content type tag declared:

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

Additionally, when var_dumping the output into the browser the characters display correctly which lead me into thinking that perhaps the database was not storing in UTF-8. I have checked this and when manually inserting the characters and storing them via phpMyAdmin these store perfectly fine.

So the problem seems to lie somewhere just before storing the data in the database, so to check this I enclosed the data in:

 utf8_encode(string)

Right before saving into the database and this resolves the problem. Now I don't feel this is a permanent solution but I cannot seem to figure out why this is happening.

I have tried adjusting tinyMCE encoding to 'raw':

       tinymce.init({
       entity_encoding : "raw"
    });

but this has not resolved the issue, can anyone shed some light into what might be happening here?


回答1:


Instead of ’, you were expecting , correct? That's Mojibake, which usually implies that you failed to declare the table column to be CHARACTER SET utf8.

Do not use utf8_encode().



来源:https://stackoverflow.com/questions/31051710/utf-8-issues-with-tinymce

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!