Archive for August, 2010

Problems with Japanese characters in MODx

August 5, 2010

Was having a problem with Japanese characters on a multi-lingual MODx site. I could see that the correct characters were being INSERTed into the database, but when I queried it directly after the insert I got just question marks out.

The solution was to change line 10 in manager/includes/ from this:

$database_connection_method = ‘SET CHARACTER SET’;

to this:

$database_connection_method = ‘SET NAMES’;

The difference between ‘SET CHARACTER SET’ and ‘SET NAMES’ is ‘SET NAMES’ tells mysql server what character set is going to be used in the connection between the server and the client (rather than just what charset will be used on the server and on the client themselves). Because it wasn’t being used, the mysql server was just guessing the character set, and guessing it wrong.