将mysqlx :: value转换为带有特殊字符的std ::字符串
Converting mysqlx::Value to std::string with special characters
我正在尝试转换一个应该是字符串的mysqlx ::值类型,但其中包含特殊的非标准语言字符。我需要将其作为std :: string或等效。
我正在使用mySQL C 连接器xdevapi检索数据。
mysqlx::Session sess(_db_conn_info.db_host, _db_conn_info.db_port, _db_conn_info.db_user, _db_conn_info.db_pass);
mysqlx::Schema db = sess.getSchema(_db_conn_info.db_name);
mysqlx::Table artist_table = db.getTable("Artist");
mysqlx::RowResult artist_result = artist_table.select("id", "a_id", "name", "is_australian")
.where("id like :artist_id").bind("artist_id", artist_id).execute();
mysqlx::Row row = artist_result.fetchOne();
行[2]值中的名称列有时可能包含以下字符:é
我想将mySQLX ::值结果传递到std ::字符串对象或类似的情况下。注意:当字符串不包含特殊字符时,此功能正常。
我尝试使用弦流,但是当字符串包含特殊字符时,我会得到" CDK错误:字符串转换错误"。
std::stringstream name;
name << row[2]; // Exception throws here
编辑:Ubuntu 18.04,GCC 7.3.0
事实证明,我正在使用MySQL-CPP-Connector的版本,该版本具有带有UTF8MB4字符编码的已知错误。(/撕开头发),升级修复。
相关文章:
- 如何用转义符替换字符串中的所有特殊字符
- 转换特殊字符(UTF-8)
- 反转字符串中单词的位置,而不更改 O(1) 空格限制中特殊字符的顺序
- 如何在C++中打印此"█"特殊字符?
- c++为什么ifstream get()函数返回无法识别的特殊字符
- 如何检查字符串是否包含所有这些:数字、字母和特殊字符
- 转义std::字符串中的特殊字符
- SDL2加载具有特殊字符的文件
- 将 std::string 转换为具有特殊字符的 FString (TCHAR / wstring)
- 如何从文本文件C++读取整数和特殊字符
- USB序列号显示特殊字符
- 键入特殊字符并保存在文件中
- 将mysqlx :: value转换为带有特殊字符的std ::字符串
- std::setw() 将特殊字符视为两个字符
- C 中的特殊字符的子字符串(STD :: substr)
- 读取 std::string,从 std::string 中删除所有特殊字符
- 如何将 std::string 中的所有非字母字符(数字和特殊字符)替换为空格
- 防止解释 std::regex 中的特殊字符
- 使用std::wifstream读取带有特殊字符的unicode文件
- c++ std::包含特殊字符的字符串搜索