Quantcast
Channel: MySQL Forums - Connector/C++
Viewing all articles
Browse latest Browse all 527

Retrieving UTF8 strings from DB (1 reply)

$
0
0
Hello,
I need to use ms vc++ with connector/c++. I can't, hovewer, get any utf8 string out of the db succesfully. Can someone point out to me what am i doing wrong or what could be missing in my approach?

First of all, my win32 app is unicode, i thought since my db is utf8 - unicode is the appropriate thing. I already wrote a function that converts e.g. mysql error messages to wchar_t* using mbstowcs_s.

When it came to converting actual string field data though, i saw that getString.c_str() points to a string which contains two-byte garbage in place of e.g. french or polish character. I thought _mbstrlen would count them properly, but no, it counts any multibyte character as two characters. Then i thought maybe mbstowcs_s would "glue" together these two bytes, but no, it treats them as two distinct characters.

What can i do to properly handle utf8 strings? Database must stay utf8 and i am already doing SET NAMES UTF8, which did not change a thing. Please assist.

Viewing all articles
Browse latest Browse all 527

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>