【问题标题】:Mysql Field Encoding issueMysql字段编码问题
【发布时间】:2020-11-27 03:52:56
【问题描述】:

如果我没有尝试一切,我真的不会问这个,但是我似乎无法解码以下 MYSQL 描述字段字符串。

“Let’s

我尝试在MYSQL中执行以下语句无济于事。

update mytable set mycolumn = 
    convert(binary convert(mycolumn using latin1) using utf8);

这会将字符串解码为âLetâs go there,â,这显然仍然不正确。

是否有其他人可以通过其他指针来解决这个问题?除了这种跨越数千个字段的字符编码之外,还有更多示例。

谢谢

【问题讨论】:

  • 你没有办法确定原始字符集吗?
  • @LarsSkaug 不幸的是,这是由供应商数据馈送提供的。
  • 它应该说什么? (有时通过相反的方向更容易弄清楚。)你还有另一个例子吗?

标签: mysql utf-8 character-encoding


【解决方案1】:

它可能不是 MySQL 识别的字符集。运行 SHOW CHARACTER SET; 会返回 MySQL 中可用的所有字符集,因此可以为所有字符集运行脚本。

我猜,看起来正确的人会是赢家。如果它们都不正确,您可能需要在 MySQL 之外对其进行解码。

select convert(binary convert(mycolumn using armscii8 ) using utf8) txt, 1 union
select convert(binary convert(mycolumn using ascii ) using utf8) txt, 2 union
select convert(binary convert(mycolumn using big5 ) using utf8) txt, 3 union
select convert(binary convert(mycolumn using binary ) using utf8) txt, 4 union
select convert(binary convert(mycolumn using cp1250 ) using utf8) txt, 5 union
select convert(binary convert(mycolumn using cp1251 ) using utf8) txt, 6 union
select convert(binary convert(mycolumn using cp1256 ) using utf8) txt, 7 union
select convert(binary convert(mycolumn using cp1257 ) using utf8) txt, 8 union
select convert(binary convert(mycolumn using cp850 ) using utf8) txt, 9 union
select convert(binary convert(mycolumn using cp852 ) using utf8) txt, 10 union
select convert(binary convert(mycolumn using cp866 ) using utf8) txt, 11 union
select convert(binary convert(mycolumn using cp932 ) using utf8) txt, 12 union
select convert(binary convert(mycolumn using eucjpms ) using utf8) txt, 13 union
select convert(binary convert(mycolumn using euckr ) using utf8) txt, 14 union
select convert(binary convert(mycolumn using gb18030 ) using utf8) txt, 15 union
select convert(binary convert(mycolumn using gb2312 ) using utf8) txt, 16 union
select convert(binary convert(mycolumn using gbk ) using utf8) txt, 17 union
select convert(binary convert(mycolumn using geostd8 ) using utf8) txt, 18 union
select convert(binary convert(mycolumn using greek ) using utf8) txt, 19 union
select convert(binary convert(mycolumn using hebrew ) using utf8) txt, 20 union
select convert(binary convert(mycolumn using hp8 ) using utf8) txt, 21 union
select convert(binary convert(mycolumn using keybcs2 ) using utf8) txt, 22 union
select convert(binary convert(mycolumn using koi8r ) using utf8) txt, 23 union
select convert(binary convert(mycolumn using koi8u ) using utf8) txt, 24 union
select convert(binary convert(mycolumn using latin1 ) using utf8) txt, 25 union
select convert(binary convert(mycolumn using latin2 ) using utf8) txt, 26 union
select convert(binary convert(mycolumn using latin5 ) using utf8) txt, 27 union
select convert(binary convert(mycolumn using latin7 ) using utf8) txt, 28 union
select convert(binary convert(mycolumn using macce ) using utf8) txt, 29 union
select convert(binary convert(mycolumn using macroman ) using utf8) txt, 30 union
select convert(binary convert(mycolumn using sjis ) using utf8) txt, 31 union
select convert(binary convert(mycolumn using swe7 ) using utf8) txt, 32 union
select convert(binary convert(mycolumn using tis620 ) using utf8) txt, 33 union
select convert(binary convert(mycolumn using ucs2 ) using utf8) txt, 34 union
select convert(binary convert(mycolumn using ujis ) using utf8) txt, 35 union
select convert(binary convert(mycolumn using utf16 ) using utf8) txt, 36 union
select convert(binary convert(mycolumn using utf16le ) using utf8) txt, 37 union
select convert(binary convert(mycolumn using utf32 ) using utf8) txt, 38 union
select convert(binary convert(mycolumn using utf8 ) using utf8) txt, 39 union
select convert(binary convert(mycolumn using utf8mb4 ) using utf8) txt, 40 union
 

【讨论】:

  • 谢谢 Lars,我会尽快完成。
  • 不幸的是,这些都没有转换为可读的东西。
【解决方案2】:

接近于“双重编码”

‘Let‛s

以下是一些可能相关的字符:

E28098     8216=x2018  [‘]   ON  LEFT SINGLE QUOTATION MARK
E2809A     8218=x201A  [‚]   ON  SINGLE LOW-9 QUOTATION MARK
E2809B     8219=x201B  [‛]   ON  SINGLE HIGH-REVERSED-9 QUOTATION MARK
E2809C     8220=x201C  [“]   ON  LEFT DOUBLE QUOTATION MARK

请提供SELECT HEX(col),我认为可能有一个字节在粘贴到此网页时丢失了。而且我认为â 来自解码尝试,该尝试因缺少字节而被截断而失败。

当文本被错误地标记为 latin1,然后存储到表中的 utf8 列中时,会发生“双重编码”。然后重复。

更多:Trouble with UTF-8 characters; what I see is not what I stored

更多报价:http://mysql.rjweb.org/doc.php/charcoll#quotes

关于 Mojibake 的更多信息:http://mysql.rjweb.org/doc.php/charcoll#8_bit_encodings(见第二张表)

【讨论】:

  • 20C383C2A2C382E282ACC382C5934C6574C383C2A2C382E282ACC382E284A273 这是所请求字符串的十六进制返回值。也感谢您提供的信息。
  • 我很难过。你能解释一下字符串的历史——它是如何存储、复制等的吗?每一步的设置是什么;等
  • 这是产品描述的一小部分。该数据最初是通过我们的供应商之一提供的 CSV 文件提取的。然后将其解析并过滤到 sim 产品数据库中。每天一次,我们每个客户站点上的产品都会通过从电子商务到产品 sim DB 的 CRON 作业进行更新。今晚经过一番调查。这是直接从我们的供应商 CSV 提供的字符串的原始副本。 “Letâ‚‚¬Ã‚‚â„¢s
  • @Juakali92 - 供应商是否可能使用某些非英语语言?有几十个字符集。假设 latin1 是该过程的一部分,我没有得到任何结果。相反,如果使用其他编码,我可能会取得更大的成功。
  • 他们是一家美国公司,令一个知名品牌感到沮丧,这使得通过正确的渠道进行沟通变得困难。我们之前尝试过询问使用哪种字符集无济于事。看来我们需要尝试再询问一次
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2010-12-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-01-02
相关资源
最近更新 更多