MySQL warning: Incorrect string value: '\x96

会有一股神秘感。 提交于 2021-01-28 18:35:23

问题


I'm trying to import a CVS file where I get this warning: 1366 Incorrect string value: '\x96 PART...' for column

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.


回答1:


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.

Plan A: Change the file. (This is probably not practical.)

Plan B: Tell MySQL that the file is latin1 (as opposed to utf8). Then MySQL will convert it correctly to the utf8-encoding E28093.

"Collation" has to do with sorting and comparing; "Character set" has to do with 'encoding'.

Add this to the LOAD DATA statement that I assume you are using:

CHARACTER SET latin1

Reference.



来源:https://stackoverflow.com/questions/35640262/mysql-warning-incorrect-string-value-x96

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!