UTF-8编码与互联网浏览器%u20AC到&欧元; [英] UTF-8 Encoding with internet explorer %u20AC to €

查看:392
本文介绍了UTF-8编码与互联网浏览器%u20AC到&欧元;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用TinyMCE作为我的CMS用户的HTML编辑器。
不知何故,欧元符号(€)由IE(任何)转换为%u20AC。

I'm currently using TinyMCE as html editor for users of my CMS. Somehow the euro symbol (€) is converted to %u20AC by IE (any).

经过短时搜索,我发现这个。它为UTF-8欧元符号的不同编码提供了很多,但不是%u20AC,带有百分比图标。

After a short search I found this. It gives a lot for different encodings for the UTF-8 euro symbol, but not %u20AC, with the percentage icon.

我给了适用于UTF-8的标题,所以我告诉IE只是粗鲁地做事情自己的方式...

I have given the proper headers for UTF-8, so I gues IE is just being rude doing things its own way...

有没有一个PHP函数可以捕获这个奇怪的编码,并把它放在正常的htmlentity(十六进制,十进制或命名)。我可以只是 string_replace()这个单一的问题符号,但我宁愿立即修复所有可能的冲突。

Is there a PHP function that can catch this strange encoding and put it to normal htmlentity (hex,decimal or named). I could just string_replace() this single problem symbol, but I'd rather fix all possible conflicts at once.

或者我应该简单地将%u 替换为& #x 禁用%u的正常使用

Or should I simply replace %u with &#x disabling normal usage of %u?

推荐答案

%u20AC 的Unicode编码数据€它由JavaScript的 escape()函数生成为UTF8,用于服务器端处理。

%u20AC is Unicode-encoded data for which is generated by JavaScript's escape() function to UTF8 for server-side processing.

标准PHP urldecode不能处理它,所以你需要使用扩展例程:

Standard PHP urldecode can not deal with it, so you need to use an extended routine:

/**
 * @param string $str unicode and ulrencoded string
 * @return string decoded string
 */
function utf8_urldecode($str) {
    $str = preg_replace("/%u([0-9a-f]{3,4})/i","&#x\\1;",urldecode($str));
    return html_entity_decode($str,null,'UTF-8');;
}

还要检查是否可以为TinyMCE配置此行为。

Also check if you can configure this behaviour for your TinyMCE.

这篇关于UTF-8编码与互联网浏览器%u20AC到&欧元;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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