UTF-8 在 HTML 表单中不起作用 [英] UTF-8 not working in HTML forms

查看:33
本文介绍了UTF-8 在 HTML 表单中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个表格:

<form method="post" enctype="multipart/form-data" accept-charset="UTF-8">

但是当我提交 é 字符时,它会变成 é.

But when I submit an é character, it turns it into é.

为什么这不起作用?是的,MySQL 数据库已正确设置所有字符集.(数据库,表格.)如果我用 Navicat 手动将它放入数据库,它会在网页上正常显示.

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.

推荐答案

在你的 HTML 中,添加这个元标记:

In your HTML, add this meta tag:

 <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">

还要在脚本顶部添加此 PHP 标头:

Also add this PHP header at top of the script:

 header("Content-Type: text/html;charset=UTF-8");

:

另外一个技巧是将文件保存为 UTF-8 without BOM 编码.您可以使用 Notepad++ 或任何不错的编辑器来执行此操作.

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屋!

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