UTF-8在HTML表单中不起作用 [英] UTF-8 not working in HTML forms
问题描述
我有这种形式:
< form method =postenctype =multipart / form-dataaccept -charset =UTF-8>
但是当我提交一个é字符,它会变成é。
为什么这不工作?是的,MySQL数据库具有正确设置的所有字符集。 (数据库,表。)如果我手动将它放在数据库与Navicat它在网页上显示罚款。
此外,我试过了元标记,
在您的HTML中,添加此元标记:
< meta http-equiv =Content-Typecontent =text / html; charset = UTF-8>
还要在脚本顶部添加这个PHP标题:
header(Content-Type:text / html; charset = UTF-8);
:
另一个提示是将文件保存为
UTF-8没有BOM
编码。您可以使用记事本++ 或任何正式的编辑器来执行此操作。I have this form:
<form method="post" enctype="multipart/form-data" accept-charset="UTF-8">
But when I submit an é character, it turns it into é.
Why doesn't this work? Yes, the MySQL database has all the character-sets set up correctly. (Database, tables.) If I manually put it in the database with Navicat it shows up fine on the webpage.
Also, I have tried the metatag, setting the content-type header, without success.
解决方案In your HTML, add this meta tag:
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
Also add this PHP header at top of the script:
header("Content-Type: text/html;charset=UTF-8");
[EDIT]:
One more tip is to save the file as
UTF-8 without BOM
encoding. You can use Notepad++ or any decent editor to do that.这篇关于UTF-8在HTML表单中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!