使用C ++使用Mysql进行Unicode数据传输 [英] Unicode Data transfer Using Mysql by C++
本文介绍了使用C ++使用Mysql进行Unicode数据传输的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我正在尝试发送unicode数据,例如日本语使用C ++代码将Mysql源表转换为Mysql目标表,但日语用???代替.的话,我尝试使用连接字符串utf-8,但没有用.
任何解决方案..
解决方案
UNICODE是16位的,可能是低位字节序(或检查字节序).
如果我没有记错,您会以字节流的形式接收它们.将它们传递给wchar_t类型.但我不确定这是否是问题.
另一件事:如果仅将数据存储为UTF-8,则可以读取为UTF-8.如果要将UTF-8转换为UTF-16,请使用 mbstowcs 函数
开始检索数据之前,应选择编码类型:
SET 名称' charset_name ' [收集 ' collation_name' span>];
UNICODE is 16 bit, and probably as little endian(or check for endianess).
if i am not wrong you receive them as byte stream. Transfer them wchar_t type. but I am not sure if this is the problem.
Another thing If you store data as UTF-8 only then you can read as UTF-8. If you want to transfer UTF-8 to UTF-16 then use mbstowcs function
before you start retrieving data you should select the encoding type:
SET NAMES 'charset_name' [COLLATE 'collation_name'];
这篇关于使用C ++使用Mysql进行Unicode数据传输的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文