tags:

views:

55

answers:

1

Hi all,

I have a wchar_t string, for example, L"hao123--我的上网主页", I can convert it to utf8

encoding, the output string is "hao123锛嶏紞鎴戠殑涓婄綉涓婚〉", but finally, I must write this

string to a plain text file, its format is utf16 (I know this from others), "hao123\uFF0D\uFF0D\u6211\u7684\u4E0A\u7F51\u4E3B\u9875".

Because I must save it in C++ std string and then write it to a file, How can I convert

"hao123锛嶏紞鎴戠殑涓婄綉涓婚〉" to "hao123\uFF0D\uFF0D\u6211\u7684\u4E0A\u7F51\u4E3B\u9875" in char or C++ std string ?

Can anyone give me some tips?

Thanks in advance!

A: 

I wrote on conversion function by myself, for more information, please visit http://stackoverflow.com/questions/2679964/c-unicode-utf-16-encoding

Dan