CKEditor 字符集

发布于 2024-11-19 15:00:58 字数 1201 浏览 0 评论 0原文

我更新了我的网络应用程序以使用 UTF-8 而不是 ANSI。

我采取了以下措施来定义字符集:

mysql_set_charset("utf8"); // PHP
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> // HTML
utf8_general_ci // In MySQL

我还编辑了 CKEditor 配置以删除 htmlentities,因为我需要 MySQL 的正确字符(即 é 而不是 é)全文搜索。

config.entities = false;
config.entities_latin = false;

在数据库(phpMyAdmin 视图)和普通文本字段输出(HTML、

然而,CKEditor 在编码方面存在一些问题。请参阅附图,了解从数据库中获取的同一字段,显示在文本区域中,然后显示在由 CKEditor 替换的文本区域中: CKEditor Encoding Problems

这似乎在 CKEditor JavaScript 代码中(可能是固定字符集),但我找不到它在配置中。同样,由于 é 在正常 HTML 中正确显示(真正的 UTF-8 é,而不是 &eacute; 也不是 é< /code>),我很确定这不是 PHP/MySQL 查询错误(但我可能是错的)。

编辑:这似乎是应用 htmlentities 的症状,默认情况下,它在 UTF-8 文本上以 Latin-1 编码。可以使用 htmlspecialchars 或指定字符集(“utf-8”),但我不知道在 CKEditor 中在哪里修改它

I updated my web app to use UTF-8 instead of ANSI.

I did the following measures to define charset:

mysql_set_charset("utf8"); // PHP
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> // HTML
utf8_general_ci // In MySQL

I also edited the CKEditor config to remove htmlentities because I need the correct character (i.e. é and not é) for MySQL fulltext search.

config.entities = false;
config.entities_latin = false;

In the database (phpMyAdmin view) and on normal text fields output (HTML, <input> or <textarea>), everything looks fine (I see é, not é, not é, yay).

However, CKEditor has some trouble with the encoding. See attached image for the same field taken from the database, displayed in a textarea, then in a textarea repalced by CKEditor:
CKEditor Encoding Problems

This seems to be in the CKEditor JavaScript code (probably a fixed charset), but I can't find it in the config. Again, since the é displays correctly in normal HTML (real UTF-8 é, not é nor é), I'm quite sure it's not the PHP/MySQL query that's wrong (but I might be mistaken).

EDIT: This seems like a symptom of applying htmlentities, which by default is encoded in Latin-1, on UTF-8 text. There is either a possibility of using htmlspecialchars or to specify the charset ("utf-8"), but I don't know where to modify that in CKEditor.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

∞觅青森が 2024-11-26 15:00:58

该线程似乎有点过时,但回答它可以帮助任何寻求回应的人。

允许CKEditor将字符é处理为é而不是é;将 entities_latin 的配置设置为 false,如下所示:

config.entities_latin = false;

或者,您可能只想将以下选项设置为 false:

config.entities = false;
config.basicEntities = false;

This thread seems bit dated but answering it to help anyone looking for a response.

To allow CKEditor to process the character é as é and not é; set the config for entities_latin to false, as below:

config.entities_latin = false;

Or, you may just want to set following options to false:

config.entities = false;
config.basicEntities = false;
墟烟 2024-11-26 15:00:58

错误的是我的方法,而不是 CKEditor 的方法。查找了错误的文件并错过了 htmlspecialchars 上的 UTF-8 编码。

It was my approach that was wrong, not CKEditor's. Was looking in the wrong file and missed the UTF-8 encoding on a htmlspecialchars.

可是我不能没有你 2024-11-26 15:00:58

您还可以在数据库连接中使用:$connection->query("SET NAMES 'utf8'");
并记住将数据库和/或表排序规则设置为utf8...我更喜欢utf8_general_ci

You can also use in your database connection: $connection->query("SET NAMES 'utf8'");
And remember to set db, and/or table Collation to utf8... I prefer utf8_general_ci

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文