問題描述
我有這個表格:
<form method="post" enctype="multipart/form-data" accept-charset="UTF-8">
但是當我提交 é 字符時,它會變成 ??.
But when I submit an é character, it turns it into ??.
為什么這不起作用?是的,MySQL 數(shù)據(jù)庫已正確設置所有字符集.(數(shù)據(jù)庫,表格.)如果我用 Navicat 手動將它放入數(shù)據(jù)庫,它會在網(wǎng)頁上正常顯示.
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.
另外,我嘗試了元標記,設置了內(nèi)容類型標頭,但沒有成功.
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++ 或任何不錯的編輯器來執(zhí)行此操作.
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 表單中不起作用的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!