简体   繁体   English

UTF-8与tinymce有关吗?

[英]UTF-8 issues with tinymce?

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. 从Word文档粘贴到tincymce hmtl编辑器时,遇到卷曲引号和撇号的某些问题,由于某种原因,它将这些字符转换为Â,’等。

Things I have checked: 我检查过的事情:

Firstly I have ensured all the html pages all have the correct content type tag declared: 首先,我确保所有html页面都声明了正确的内容类型标记:

<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. 另外,当var_dump输出到浏览器中时,字符正确显示,这使我想到数据库可能没有存储在UTF-8中。 I have checked this and when manually inserting the characters and storing them via phpMyAdmin these store perfectly fine. 我已经检查了这一点,当手动插入字符并通过phpMyAdmin存储它们时,这些存储就很好了。

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编码调整为“原始”:

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

but this has not resolved the issue, can anyone shed some light into what might be happening here? 但这并不能解决问题,任何人都可以弄清楚这里可能发生的情况吗?

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 . 那就是Mojibake,这通常意味着您未能将表列声明为CHARACTER SET utf8

Do not use utf8_encode() . 不要使用utf8_encode()

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

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