浏览器显示的不是“ [英] Browser displays � instead of ´

查看:132
本文介绍了浏览器显示的不是“的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有具有以下文本的php文件:

I have a php file which has the following text:

<div class="small_italic">This is what you´ll use</div>

在一台服务器,它显示为:

On one server, it appears as:

This is what you´ll use

和另一个,如:

This is what you�ll use

为什么会有一个差异,我能做些什么,使之正确显示(撇号)?

Why would there be a difference and what can I do to make it appear properly (as an apostrophe)?

注意所有(备查)

我实现戈登/秋葵的建议,但我实现它在服务器级别而不是应用水平。需要注意的是(一)我不得不重新启动Apache服务器和更重要的是,(B),我与在正确的编码的校正数据,以取代现有的坏数据

I implemented Gordon's / Gumbo's suggestion, except I implemented it on a server level rather than the application level. Note that (a) I had to restart the apache server and more importantly, (b) I had to replace the existing "bad data" with the corrected data in the right encoding.

/etc/php.ini中

/etc/php.ini

DEFAULT_CHARSET =ISO-8859-1

default_charset = "iso-8859-1"

推荐答案

您必须确保,内容供应与适当的字符集:

You have to make sure, the content is served with the proper charset:

或者发送与包括

<?php header("Content-Type: text/html; charset=[your charset]"); ?>

或 - 如果HTTP字符集不存在头文件的 - 插入 &LT ; META&GT; 元素&LT; HEAD&GT;

or - if HTTP charset headers don't exist - insert a <META> element into the <head>

<meta http-equiv="Content-Type" content="text/html; charset=[your charset]" />

像属性顾名思义HTTP的当量是一个HTTP响应报头和用户代理应的情况下,相应的HTTP标头未设置使用它们的等同物。

Like the attribute name suggests http-equiv is the equivalent of an http response header and user-agents should use them in case the corresponding http headers are not set.

EDIT1:就像汉纳斯在评论这个问题已经建议,你可以看看你的网络服务器返回,看看哪些编码它服务的头。有可能两个服务器之间的差异。所以更改上面的工作服务器的 [您的charset] 部分。

Like Hannes already suggested in the comments to the question, you can look at the headers returned by your webserver to see which encoding it serves. There is likely a discrepancy between the two servers. So change the [your charset] part above to that of the "working" server.

EDIT2 有关更详尽的解释,说明为何看到甘博的回答

EDIT2 for a more elaborate explanation about the why, see Gumbo's answer.

这篇关于浏览器显示的不是“的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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