UTF-8与tinymce有关的问题? [英] UTF-8 issues with tinymce?

查看:230
本文介绍了UTF-8与tinymce有关的问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从Word文档粘贴到tincymce hmtl编辑器时,我遇到一些卷曲的引号和撇号问题,由于某种原因,它将这些字符转换为Â,’等.

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.

我已检查的内容:

首先,我确保所有html页面都声明了正确的内容类型标记:

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" />

此外,当 var_dumping 输出到浏览器中时,字符正确显示,这使我想到数据库可能未存储在UTF-8中.我已经检查了这一点,当手动插入字符并通过phpMyAdmin存储它们时,这些存储就很好了.

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.

我尝试将tinyMCE编码调整为原始":

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?

推荐答案

您期望使用,而不是’,对吗?那就是Mojibake,这通常意味着您未能将表列声明为CHARACTER SET utf8.

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.

请勿使用utf8_encode().

这篇关于UTF-8与tinymce有关的问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆