- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
我有一张表需要处理各种字符。字符包括Ø、®等。
我已将我的表设置为 utf-8 作为默认排序规则,所有列都使用表默认值,但是当我尝试插入这些字符时出现错误:不正确的字符串值:列 '\xEF\xBF\xBD'第 1 行的 buyerName'
我的连接字符串定义为
string mySqlConn = "server="+server+";user="+username+";database="+database+";port="+port+";password="+password+";charset=utf8;";
我不知道为什么我仍然看到错误。我是否遗漏了 .net 连接器或我的 MySQL 设置的任何内容?
--编辑--
我的(新)C# 插入语句如下所示:
MySqlCommand insert = new MySqlCommand( "INSERT INTO fulfilled_Shipments_Data " +
"(amazonOrderId,merchantOrderId,shipmentId,shipmentItemId,"+
"amazonOrderItemId,merchantOrderItemId,purchaseDate,"+ ...
VALUES (@amazonOrderId,@merchantOrderId,@shipmentId,@shipmentItemId,"+
"@amazonOrderItemId,@merchantOrderItemId,@purchaseDate,"+
"paymentsDate,shipmentDate,reportingDate,buyerEmail,buyerName,"+ ...
insert.Parameters.AddWithValue("@amazonorderId",lines[0]);
insert.Parameters.AddWithValue("@merchantOrderId",lines[1]);
insert.Parameters.AddWithValue("@shipmentId",lines[2]);
insert.Parameters.AddWithValue("@shipmentItemId",lines[3]);
insert.Parameters.AddWithValue("@amazonOrderItemId",lines[4]);
insert.Parameters.AddWithValue("@merchantOrderItemId",lines[5]);
insert.Parameters.AddWithValue("@purchaseDate",lines[6]);
insert.Parameters.AddWithValue("@paymentsDate",lines[7]);
insert.ExecuteNonQuery();
假设这是使用参数化语句的正确方法,它仍然报错
"Incorrect string value: '\xEF\xBF\xBD' for column 'buyerName' at row 1"
还有其他想法吗?
最佳答案
\xEF\xBF\xBD
是 unicode 字符 U+FFFD
的 UTF-8 编码。这是一个特殊字符,也称为“替换字符”。引自 the wikipedia page about the special unicode characters :
The replacement character � (often a black diamond with a white question mark) is a symbol found in the Unicode standard at codepoint U+FFFD in the Specials table. It is used to indicate problems when a system is not able to decode a stream of data to a correct symbol. It is most commonly seen when a font does not contain a character, but is also seen when the data is invalid and does not match any character:
看来您的数据源包含损坏的数据。也有可能您尝试使用错误的编码来读取数据。线条从何而来?
如果您无法修复数据,并且您的输入确实包含无效字符,您可以删除替换字符:
lines[n] = lines[n].Replace("\xFFFD", "");
关于c# - 不正确的字符串值 : '\xEF\xBF\xBD' for column,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11159118/
我正在使用 LXML 从网页上抓取一些文本。一些文本包括分数。 5½ 我需要将其转换为浮点格式。这些失败了: ugly_fraction.encode('utf-8') #doesn't chang
我正在尝试合并一个具有 4 个属性(ID、FIRSTNAME、LASTNAME、SCORE)的对象,使用 JPA 作为 ORM,使用 MySQL 作为 RDBMS,我只更新特定 ID 的分数并得到以下
我有一张表需要处理各种字符。字符包括Ø、®等。 我已将我的表设置为 utf-8 作为默认排序规则,所有列都使用表默认值,但是当我尝试插入这些字符时出现错误:不正确的字符串值:列 '\xEF\xBF\x
我有一张表需要处理各种字符。字符包括Ø、®等。 我已将我的表设置为 utf-8 作为默认排序规则,所有列都使用表默认值,但是当我尝试插入这些字符时出现错误:不正确的字符串值:列 '\xEF\xBF\x
我有一张表需要处理各种字符。字符包括Ø、®等。 我已将我的表设置为 utf-8 作为默认排序规则,所有列都使用表默认值,但是当我尝试插入这些字符时出现错误:不正确的字符串值:列 '\xEF\xBF\x
这是 Go blog 中的练习。 [练习:将无效的 UTF-8 字节序列放入字符串中。 (如何?)循环的迭代会发生什么?] 我所做的是 const nihongo = "\xbd日本語\xbd
我有以下字符串值:“walmart obama 👽💔” 我正在使用 MySQL 和 Java。 我收到以下异常:`java.sql.SQLException:错误的字符串值:'\xF0\x9F\x
我有以下字符串值:“walmart obama 👽💔” 我正在使用 MySQL 和 Java。 我收到以下异常:`java.sql.SQLException: Incorrect string v
我有以下字符串值:“walmart obama 👽💔” 我正在使用 MySQL 和 Java。 我收到以下异常:`java.sql.SQLException:不正确的字符串值:'\xF0\x9F\
我是一名优秀的程序员,十分优秀!