問題描述
我正在嘗試導入一個 CVS 文件,并在其中收到此警告:1366 不正確的字符串值:'\x96 PART ...' 列
I'm trying to import a CVS file where I get this warning: 1366 Incorrect string value: '\x96 PART...' for column
我在某處讀到這是關(guān)于 4 位 utf8 字符的.但是將表和列的排序規(guī)則更改為 utf8mb4 也不起作用.
I read somewhere that this is about the 4-bit utf8 characters. But changing the collation of the table and column into utf8mb4 didn't work either.
推薦答案
十六進制 96
大概是 en-dash
的 latin1
編碼> (–
).但是你已經(jīng)指定了 CSV 文件是 utf8 編碼的(或者 utf8mb4),這個字符是 utf8 無法理解的.
The hex 96
is presumably the latin1
encoding for an en-dash
(–
). But you have specified that the CSV file is utf8-encoded (or utf8mb4), this character is incomprehensible to utf8.
計劃 A:更改文件.(這可能不切實際.)
Plan A: Change the file. (This is probably not practical.)
計劃 B:告訴 MySQL 該文件是 latin1(而不是 utf8).然后 MySQL 會將其正確轉(zhuǎn)換為 utf8 編碼 E28093
.
Plan B: Tell MySQL that the file is latin1 (as opposed to utf8). Then MySQL will convert it correctly to the utf8-encoding E28093
.
整理"與排序和比較有關(guān);字符集"與編碼"有關(guān).
"Collation" has to do with sorting and comparing; "Character set" has to do with 'encoding'.
將此添加到我假設(shè)您正在使用的 LOAD DATA
語句中:
Add this to the LOAD DATA
statement that I assume you are using:
CHARACTER SET latin1
參考.
這篇關(guān)于MySQL 警告:不正確的字符串值:'\x96的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!