'+'字符未通过 CKEditor/PHP/MySQL/HTMLPurifier 保存

发布于 2024-09-12 13:11:51 字数 423 浏览 3 评论 0原文

我正在尝试让 UTF-8 编码与 CKEditor/PHP/MySQL/HTMLPurifier 一起使用。

我已将数据库表/字段的字符集转换为utf8-unicode-ci。

我在 ckeditor 配置中设置了以下内容:

config.entities = true;
config.entities_latin = true;
config.entities_greek = true;
config.entitles_processNumerical = true; 

PHP 使用默认设置的 HTMLPurifier 来净化 HTML。

我不确定我尝试接受 UTF-8 的做法是否正确,但诸如 α 之类的字符正在工作......但由于某种原因,文本中的任何“+”都会消失。

有什么想法吗?

I am trying to get UTF-8 encoding working with CKEditor/PHP/MySQL/HTMLPurifier.

I have converted the character sets of the database tables/fields to utf8-unicode-ci.

I have set the following in the ckeditor config:

config.entities = true;
config.entities_latin = true;
config.entities_greek = true;
config.entitles_processNumerical = true; 

And PHP is purifying the HTML with HTMLPurifier with the default settings.

I'm not sure if I'm doing the right thing for trying to accept UTF-8, but characters such as α are working... but for some reason, any '+' in the text just simply disappears.

Any ideas?

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

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

发布评论

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

评论(3

2024-09-19 13:11:51

确保在发布请求之前对文本进行 urlencode 编码。

如果您不对文本进行“urlencode”,则“+”字符将被视为空格。
如果您对文本进行 urlencode,则“+”字符将类似于:“%2B”。

Make sure that the text is urlencoded before post request.

If you do not 'urlencode' the text then the '+' character will be treated as space.
If you urlencode the text then the '+' character will look like: '%2B'.

肤浅与狂妄 2024-09-19 13:11:51

我在发布请求之前对文本进行了不必要的 urlencode,而 jQuery/AJAX 已经对其进行了编码。删除了 javascript encode() 和 PHP urldecode() 并解决了问题。

I had unnecessarily urlencoded the text before the post request, while jQuery/AJAX was already encoding it. Removed the javascript encode() and the PHP urldecode() and it fixed the problem.

甩你一脸翔 2024-09-19 13:11:51

对于 CKEditor 3.x 及更高版本以及 php 表单,请尝试此

include_once "ckeditor/ckeditor.php";
// The initial value to be displayed in the editor.
$initialValue = 'This is a test  - Αυτο ειναι ενα τεστ';
// Create class instance.
$CKEditor = new CKEditor();
// Path to CKEditor directory, ideally instead of relative dir, use an absolute path:
// If not set, CKEditor will try to detect the correct path.
$CKEditor->basePath = 'ckeditor/';
$CKEditor->config['height'] = 450;
$CKEditor->config['skin'] = 'kama';
**$CKEditor->config['entities_greek'] = false;**
$CKEditor->editor('MyEditor',$initialValue);

Manos The Greek

For CKEditor 3.x and greater and for php forms try this

include_once "ckeditor/ckeditor.php";
// The initial value to be displayed in the editor.
$initialValue = 'This is a test  - Αυτο ειναι ενα τεστ';
// Create class instance.
$CKEditor = new CKEditor();
// Path to CKEditor directory, ideally instead of relative dir, use an absolute path:
// If not set, CKEditor will try to detect the correct path.
$CKEditor->basePath = 'ckeditor/';
$CKEditor->config['height'] = 450;
$CKEditor->config['skin'] = 'kama';
**$CKEditor->config['entities_greek'] = false;**
$CKEditor->editor('MyEditor',$initialValue);

Manos The Greek

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