Codepage related problems with MySQL++
Code:
mysqlpp::Query acc_query = connection->query("SELECT * FROM accounts;开发者_如何学Go");
The following code produces:
_Gfirst = 0x00c67718 "SELECT * FROM accounts;ээээ««««««««юоюою"
As in Visual Studio debugger. It appears to cause my query to fail with weird results.
Has anyone else encountered it?
It's best to use UTF-8 encoding with MySQL. Code pages are a Windows-centric pre-Unicode concept. Your use of them instead of Unicode probably explains why you're having problems. While it's possible to make MySQL — and thus MySQL++ — work with Windows-style code pages, you shouldn't be doing that in 2010.
If you are using Unicode, it's probably UTF-16 encoding (Windows' native encoding in the NT derivatives), which again explains a lot.
Convert all string data into UTF-8 form before sending it to MySQL, and configure MySQL to use UTF-8 encoding in its tables.
精彩评论