MySQL comparing Japanese characters in a query as question marks
c#, character-encoding, localization, mysql
Solution
Try adding `charset=utf8` to your connection string:
`server=server;uid=my_user;password=pass;database=db;charset=utf8;`
EDIT:
Try execute this sql after connect:
`SET NAMES utf8`
Problem
I have a MySQL database with some varchar fields that can contain Latin characters or Japanese characters. There are entries that contain Japanese characters, that is not a problem. However, from my C# code, using `MySqlConnection`, I have been unable to get the correct results using Japanese characters in my `WHERE` clauses. It seems to compare the Japanese characters as though they are question marks. For example a query with `WHERE series_title LIKE '%未来警%'` does not return values where `series_title` contains "未来警", but instead returns all entries where `series_title` contains "???". Some details: - `series_title` is a `varchar(150)` with collation `utf8_general_ci`. - the `ConnectionString` for the `MySqlConnection` includes the kv pair `CharSet=utf8_general_ci` - the database does contain Japanese characters and is able to return them to the C# client - it only has problems when Japanese characters are being sent to it