MySQL Forums
Forum List  »  Connector/C++

Retrieving UTF8 strings from DB
Posted by: Krzysztof Barski
Date: May 30, 2010 07:23AM

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.

Options: ReplyQuote


Subject
Views
Written By
Posted
Retrieving UTF8 strings from DB
2997
May 30, 2010 07:23AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.