数据库文本中的奇怪字符:Ã, Ã, ¢, â‚ €, [英] Strange Characters in database text: Ã, Ã, ¢, â‚ €,

查看:22
本文介绍了数据库文本中的奇怪字符:Ã, Ã, ¢, â‚ €,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不确定这第一次发生是什么时候.

我有一个新的直销附属网站,并从批发商那里收到了产品目录的导出副本.我将其格式化并将其导入 Prestashop 1.4.4.

网站的前端包含产品文本中奇怪字符的组合:Ã, Ã, ¢, â‚ 等.它们出现在常见字符的位置,如 , - : 等.

这些字符出现在大约 40% 的数据库表中,而不仅仅是像 ps_product_lang 这样的产品特定表.

另一个网站帖子同样的问题发生在数据库连接字符串使用了不正确的字符编码类型.

在/config/setting.inc中,没有提到字符编码字符串,只提到了MySQL Engine,设置为InnoDB,与我在PHPMyAdmin中看到的一致.

我导出 ps_product_lang,用正确的字符替换这些字符的所有实例,以 UTF-8 格式保存 CSV 文件,然后使用 PHPMyAdmin 重新导入它们,指定 UTF-8 作为语言.

但是,在 PHPMyAdmin 中进行新的搜索后,我现在在 ps_product_lang 中的这些不良字符的实例数量是我开始时的 10 倍.

如果问题就像在数据库连接字符串中指定正确的语言属性一样简单,我在哪里/如何设置它,以及如何设置?

顺便说一句,我尝试在 此线程中提到的 PHPMyAdmin 中运行此命令,但问题依然存在:

SET NAMES utf8

更新:PHPMyAdmin 说:

<块引用>

MySQL 字符集:UTF-8 Unicode (utf8)

这是我在上一个导入文件中使用的相同字符集,导致更多字符损坏.在导入过程中指定了 UTF-8 作为导入文件的字符集.

更新2

这是一个示例:

<块引用>

人们真正的生活是不受束缚的────────────────────────────────────────────────────────Ã‚ï† 在线购买和租借电影、下载软件,以及在网络上共享和存储文件.

更新3

我在 PHPMyAdmin 中运行了一个 SQL 命令来显示字符集:

  • character_set_client utf8
  • character_set_connection utf8
  • character_set_database latin1
  • character_set_filesystem 二进制文件
  • character_set_results utf8
  • character_set_server latin1
  • character_set_system utf8

因此,也许我的数据库需要转换(或删除并重新创建)为 UTF-8.如果 MySQL 服务器是 latin1,这会造成问题吗?

MySQL 能否将服务内容翻译为 UTF8,但将其存储为 latin1?我不认为它可以,因为 UTF8 是 latin1 的超集.我的网络托管支持在 48 小时内没有回复.对他们来说可能太难了.

解决方案

如果表格的字符集与其内容相同,请尝试使用 mysql_set_charset('UTF8', $link_identifier).请注意,MySQL 使用 UTF8 来指定 UTF-8 编码,而不是更常见的 UTF-8.

查看我的其他回答也有类似问题.

I'm not certain when this first occured.

I have a new drop-shipping affiliate website, and receive an exported copy of the product catalog from the wholesaler. I format and import this into Prestashop 1.4.4.

The front end of the website contains combinations of strange characters inside product text: Ã, Ã, ¢, â‚ etc. They appear in place of common characters like , - : etc.

These characters are present in about 40% of the database tables, not just product specific tables like ps_product_lang.

Another website thread says this same problem occurs when the database connection string uses an incorrect character encoding type.

In /config/setting.inc, there is no character encoding string mentioned, just the MySQL Engine, which is set to InnoDB, which matches what I see in PHPMyAdmin.

I exported ps_product_lang, replaced all instances of these characters with correct characters, saved the CSV file in UTF-8 format, and reimported them using PHPMyAdmin, specifying UTF-8 as the language.

However, after doing a new search in PHPMyAdmin, I now have about 10 times as many instances of these bad characters in ps_product_lang than I started with.

If the problem is as simple as specifying the correct language attribute in the database connection string, where/how do I set this, and what to?

Incidently, I tried running this command in PHPMyAdmin mentioned in this thread, but the problem remains:

SET NAMES utf8

UPDATE: PHPMyAdmin says:

MySQL charset: UTF-8 Unicode (utf8)

This is the same character set I used in the last import file, which caused more character corruptions. UTF-8 was specified as the charset of the import file during the import process.

UPDATE2

Here is a sample:

people are truly living untetheredÃƒÆ’Ã‚Â¢ÃƒÂ¢Ã¢â‚¬Å¡Ã‚Â¬ÃƒÂ¯Ã¢â‚¬Â Ã‚ï† buying and renting movies online, downloading software, and sharing and storing files on the web.

UPDATE3

I ran an SQL command in PHPMyAdmin to display the character sets:

  • character_set_client utf8
  • character_set_connection utf8
  • character_set_database latin1
  • character_set_filesystem binary
  • character_set_results utf8
  • character_set_server latin1
  • character_set_system utf8

So, perhaps my database needs to be converted (or deleted and recreated) to UTF-8. Could this pose a problem if the MySQL server is latin1?

Can MySQL handle the translation of serving content as UTF8 but storing it as latin1? I don't think it can, as UTF8 is a superset of latin1. My web hosting support has not replied in 48 hours. Might be too hard for them.

解决方案

If the charset of the tables is the same as it's content try to use mysql_set_charset('UTF8', $link_identifier). Note that MySQL uses UTF8 to specify the UTF-8 encoding instead of UTF-8 which is more common.

Check my other answer on a similar question too.

这篇关于数据库文本中的奇怪字符:Ã, Ã, ¢, â‚ €,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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