utf-8 特殊字符不显示 [英] utf-8 special characters not displaying

查看:30
本文介绍了utf-8 特殊字符不显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将我的网站从我的本地测试服务器移到 NameCheap 共享主机,现在我遇到了一个问题 - 一些页面没有正确显示 utf-8 特殊字符(而是显示问号).所有页面都采用 utf-8 编码,所有数据库表也是如此.奇怪的是,有些页面显示正确,有些页面显示不正常,这似乎是一种随机模式.

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 脚本的开头调用 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 特殊字符不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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