GCC has -finput-charset, -fexec-charset and -fwide-exec-charset three compile options to specify particular encodings involved in a \"
Credit on @user3998276 's answer and the great experiment.
The conclusion tells me a lot
when meet L"string", wide string:
when meet "string", ordinary string literal:
As to your problem, I think the 'insertion operations on db tables' is just a call to the db insertion API. So, all you need to do is to organize the command, like SQL, in UTF8. Once the API can understand your command, it can write the right value(imagine binary steam) for you.
Try:
u8"INSERT INTO table_name (col1, col2,...) VALUES (v1, v2,....)"
http://en.cppreference.com/w/cpp/language/string_literal
Use a third-party string wrapper, like QString from QT.
First wrap your SQL to QString, then it can be easily convert to utf8, QByteArray x = mySql.toUtf8(). The
QByteArray is just 'array of byte', so you can static_cast it to the type the insertion API wants.
Again, read the answer of @user3998276 carefully, you may need to change the encoding of your cpp file to Unicode if there are some character cannot be represent in you ANSI code page.