新鲜WAMP安装中有奇怪的字符? [英] Strange character in fresh WAMP installation?

查看:126
本文介绍了新鲜WAMP安装中有奇怪的字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在新鲜的本地WAMP安装中收到奇怪字符。我刚刚从ftp在线下载了所有.php文件,并恢复了我的本地mysql服务器上的备份。只有在文字包含符号或特殊字符时才会出现此问题:





PHP < meta http-equiv =Content-Typecontent =text / html; charset = UTF-8/>



/ strong>: latin1_swedish_ci



在这张图片中, 其中,需要°和€。这在Opera和Firefox都发生过。



任何想法?感谢您的帮助。

解决方案

我会回答这里,因为它太长的评论。 / p>

您不需要更改编码,您应该检查您的编码。请记住,编码可以在很多不同的地方更改:




  • 在您的数据库中,字符集函数

  • 在您的apache配置中, AddDefaultCharset

  • 使用php < a href =http://php.net/manual/en/function.header.php =nofollow>标题功能

  • 在您的html中< meta http-equiv =Content-Typecontent =text / html; charset = utf-8> tag



任何这些原因都可能导致在网络浏览器中显示错误的编码。如果不使用一个或多个之前的方法指定它,相应的图层将使用其配置的默认值。



在你的情况下,因为文本来自数据库,因为经常在WAMP / XAAMP / MAMP MySQL中使用奇怪的默认编码,我会检查第一点。尝试执行 SET NAMES UTF-8 (或您使用的任何编码)在之前检索数据之前查询数据库连接函数。


I'm getting strange characters in my fresh local WAMP installation. I've just downloaded all .php files from ftp online and restored a backup on my local mysql server. The problem only happens when text contains symbols or special characters:

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

MySQL collation: latin1_swedish_ci

In this image of course there is a strange symbol "°" where "°" and "€" are needed. This has happened both in Opera and Firefox.

Any idea? Thanks for helping, as always.

解决方案

I'll answer here because it's too long for a comment.

You don't need to change your encoding, you should check your encoding. Keep in mind that encoding could be changed in a lot of different places:

Any of these reasons could lead to wrong encoding displayed in the web browser. And if you do not specify it with one or more the previous methods, the corresponding layer will use its configured default.

In your case since the text is coming from database and since often in WAMP/XAAMP/MAMP MySQL use a weird default encoding, I'd check for point one. Try to execute SET NAMES UTF-8 (or whatever encoding you use) query before retrieving data, just after your db connect function.

这篇关于新鲜WAMP安装中有奇怪的字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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