I have a database (Mysql) with some fields in UTF-8 (I can change that if needed).
I use an old MySQL ‘Communicator’ or its predecessor, I wrote the code ~3 years ago and all I know today is that I link with libmysql.lib and #include “mysql.h” (do tell if you want me to dig up more).
The thing is I don’t have a clue about how to insert and read non-ASCII.
I know about MultiByteToWideChar but some code compiles under Linux (gcc) so that won’t work I guess.
What is the standard procedure when it comes to getting and setting std::wstrings (or wchar_t*) from/to a MySQL database when the code should run on Linux and Windows ?
I recommend that you store your data in MySQL in UTF-8 form, rather than try to convince it to take Windows-native UTF-16. If your text is mostly Western, UTF-8 encoding will be more compact, and it will be more likely to work with the C-and-Unix nature of MySQL.
There are Visual C++ specific examples in MySQL++ that show how to do this. See
CExampleDlg::ToUTF8()and the functions that call it inexamples/vstudio/mfc/mfc_dlg.cpp, for example.There’s a chapter in the MySQL++ user manual that gives the whys and wherefores behind all this.