POST提交中的PHP重音字符 [英] PHP accented characters in POST submit

查看:78
本文介绍了POST提交中的PHP重音字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在submit.php上有一个HTML表单,页面被编码为UTF-8(使用元标记),当表单提交到process.php(通过POST)时,一些变量存储在会话,页面使用Header:Location返回submit.php,然后使用会话变量重新显示一些输入的信息。

I have a HTML form on submit.php, the page is encoded as UTF-8 (using a meta tag), when the form is submitted to process.php (via POST), some of the variables are stored in the session, and the page uses Header: Location to go back to submit.php, which then uses the session variables to redisplay some of the entered information.

如果我输入重音字符,例如é (& eacute),当页面返回submit.php时,它不会正确呈现字符,我得到一个ã (& atilde)和© (& copy)。

If I enter an accented character, for example é (&eacute), when the page returns to submit.php, it does not render the character correctly, I get an ã (&atilde) and an © (&copy) instead.

我应该在哪里寻找解决这个问题?我假设它是服务器端,因为渲染的页面总是UTF-8(浏览器在提交前后确认页面是UTF-8)

Where should I be looking to solve this problem? I'm assuming it's server side, as the rendered page is always UTF-8 (the browser confirms the page is UTF-8 before and after submitting)

解决方案:

字符串在某一点被传递通过htmlentities(),结果证明它具有ISO-8859-1的默认字符编码。答案是在函数调用中简单指定UTF-8。

The string was being passed through htmlentities() at one point, which it turns out has a default character encoding of ISO-8859-1 The answer was to simply specify 'UTF-8' in the function call.

推荐答案

é变成〜©是一个确定的标志,2字节的UTF-8字符在某点被解释为1字节的字符集最可能的ISO-8859-1)。

é being turned into is a sure-fire sign that the 2-byte UTF-8 character at some point gets interpreted in a 1-byte character set (most likely ISO-8859-1).

您需要找到发生这种情况的地方,并修复它。

You need to find where this happens, and fix it.

也许显示一些代码 - 一个主意。

Maybe show some code - maybe somebody has an idea.

这篇关于POST提交中的PHP重音字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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