[英]Insert UTF-8 txt file into MySql results in ErrorCode 1366
I am trying to insert a delimited txt file into MySQL but it seems there is something wrong with the encoding. 我正在尝试将分隔的txt文件插入MySQL,但是似乎编码有问题。 I get Error coe 1366:Incorrect string value in in MYSQL when I try and insert.
尝试插入时,我在MYSQL中收到错误coe 1366:不正确的字符串值。 When I open the txt file it looks like this on the line that caused the error.
当我打开txt文件时,看起来是在导致错误的行上。
Any idea how can I insert this data? 知道如何插入此数据吗?
You need to escape special characters. 您需要转义特殊字符。 Something like
\\'
for quote and so on 像
\\'
的报价等等
Somehow hex 9C
got into the file. 十六进制
9C
不知何故进入了文件。 In latin1, that is œ
. 在latin1中,即
œ
。
Plan A: 计划A:
Edit the file to remove it. 编辑文件以将其删除。 The text around there is all in uppercase English, so I suspect it was not supposed to be
œ
. 周围的文字全都是大写英文,所以我怀疑它应该不是
œ
。
Plan B: 方案B:
Use the charset option to set the incoming stream to latin1
. 使用charset选项将传入流设置为
latin1
。 Then deal with œ
later (or not). 然后处理
œ
以后(或不进行)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.