Mysql Проблема с кодировкой полей - PullRequest
0 голосов
/ 06 августа 2020

Я действительно не стал бы спрашивать об этом, если бы я не все пробовал, однако я не могу расшифровать следующую MYSQL строку поля описания.

“Let’s

Я попытался выполнить следующую инструкцию в MYSQL безрезультатно.

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

Это декодирует строку в âLetâs go there,â, что, очевидно, все еще неверно.

Есть ли какие-нибудь другие указатели, которые кто-то мог передать, чтобы решить эту проблему? Есть больше примеров, чем просто эта кодировка символов в тысячах полей.

Спасибо

Ответы [ 2 ]

1 голос
/ 07 августа 2020

Это может быть не тот набор символов, который распознает 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
 
0 голосов
/ 07 августа 2020

Это похоже на "двойное кодирование"

‘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 столбец в таблице. Затем это повторяется.

Еще: Проблемы с символами UTF-8; я вижу не то, что я сохранил

Подробнее о цитатах: http://mysql.rjweb.org/doc.php/charcoll#quotes

Подробнее о Mojibake: http://mysql.rjweb.org/doc.php/charcoll#8_bit_encodings ( см. вторую таблицу)

...