Link to home
Start Free TrialLog in
Avatar of poor_guy
poor_guy

asked on

CDaoDatabase unicode problem

Hi,
I am writing an application which is a console based program using CDAODatabase and another static library.  The library i am using cannot handle unicode builds of the application, so I have to build it using multibyte.  The values in the database are in unicode, my problem is that the values returned from the database are in multibyte.  Does anyone know how to retrieve the value in unicode with a multibyte build?  Thanks in advance.
Avatar of nonubik
nonubik

You need to convert each value returned from database from multibyte to unicode, using mbstowcs(..) function, for example.
Avatar of poor_guy

ASKER

Thanks for the reply.
I've tried that, but when the values are retrieved from DB, it is converted to multibyte chars and the multibyte chars are all converted to the default locale of the OS.  So the data in other langauages becomes question marks.  eg) my locale is in chinese, my DB has english, chinese, japanese and korean, after i get the data, they are all converted to chinese, so the japanese and korean data becomes garbage.  Therefore, using the mbstowcs function will only change the english and chinese data to unicode.
ASKER CERTIFIED SOLUTION
Avatar of nonubik
nonubik

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks nonubik, but using setlocale would mean that I have to know the language for each record before I retrieve them, which is not possible in my case because the application that inputs the value allows the user to input unicode data and I have no idea what the user's input language is.  The only way that I can think of is to retrieve wide characters from the database from a multibyte build and I've been searching for days and couldn't figure out how.  Please Help!
Anyone have any suggestions? Thanks.