MySQL排序规则和PHP字符集冲突 [英] MySQL collation and PHP charset conflict

查看:209
本文介绍了MySQL排序规则和PHP字符集冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一堆从拉丁1 MySQL数据库取得的丹麦语文本,并且在PHP中回显时可以正确显示。

I have a bunch of Danish text taken from a latin-1 MySQL database and it displays correctly when echoed in PHP. The problem starts when I need to echo some other Danish characters, which are not taken from the database.

我要做的就是输出标题

Content-Type: text/html; charset=iso-8859-1

也可以让非查询字符正确显示。

to also let the non-queried characters to display correctly as well.

问题是,当我这样做时,查询的字符显示不正确。

Problems is, when I do that the queried characters display incorrectly.

推荐答案

只是因为数据存储在拉丁-1整理表中并不意味着它是拉丁-1编码的。这是因为当连接 SET NAMES 设置与排序规则相同时,MySQL不会进行任何字符翻译。

Just because the data is stored in a latin-1 collated table doesn't mean that it's latin-1 encoded. This is due to MySQL not doing any character translation when the connection SET NAMES setting is the same as the collation.

我怀疑你有一些存储在latin1数据库中的UTF8字符,这使得问题变得混乱。

I suspect that you have some UTF8 characters stored in a latin1 database which is confusing the issue.

有关更多帮助,请添加以下内容:

For more help please can you add details of the:


  • 您设置的MySQL连接编码

  • 非查询字符来自的详细信息

这篇关于MySQL排序规则和PHP字符集冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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