問題描述
我將我的網(wǎng)站從我的本地測試服務器移到 NameCheap 共享主機,現(xiàn)在我遇到了一個問題 - 一些頁面沒有正確顯示 utf-8 特殊字符(而是顯示問號).所有頁面都采用 utf-8 編碼,所有數(shù)據(jù)庫表也是如此.奇怪的是,有些頁面顯示正確,有些頁面顯示不正常,這似乎是一種隨機模式.
I moved my website from my local test server to NameCheap shared hosting and now I'm running into a problem - some of the pages aren't displaying utf-8 special characters properly (showing question marks instead). All pages are utf-8 encoded, as are all database tables. The strange thing is, some pages display correctly and some don't, in a seemingly random pattern.
例如,我的索引頁很好,但我的個人資料頁就不行.faq.html 工作正常,但是當我將其重命名為 faq.php 時卻沒有.最奇怪的是,我有一個包含兩個 JQuery 選項卡的頁面,其中一個顯示正確,另一個顯示不正確!
For instance, my index page is fine, but my profile page isn't. faq.html works fine, but when I rename it to faq.php it doesn't. And weirdest of all, I have a page with two JQuery tabs where one displays correctly and the other doesn't!
有人可以幫我解決這個問題嗎?
Can someone help me out with this?
推薦答案
這個問題確實很煩人,但你可以試試這些.
This is really annoying problem to fix but you can try these.
首先,確保文件實際上是以UTF-8格式保存的.
First of all, make sure the file is actually saved in UTF-8 format.
然后檢查您的 HTML 標頭中是否有 <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
.
Then check that you have <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
in your HTML header.
您也可以嘗試在 PHP 腳本的開頭調(diào)用 header('Content-Type: text/html; charset=utf-8');
或添加 AddDefaultCharset UTF-8
到您的 .htaccess 文件.
You can also try calling header('Content-Type: text/html; charset=utf-8');
at the beginning of your PHP script or adding AddDefaultCharset UTF-8
to your .htaccess file.
這篇關于utf-8 特殊字符不顯示的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!