Ahhh character encodings. Don’t you just love them?
Having character issues in MODx? Then probably the MODx manager character encoding, the character encoding of the site itself, your database’s character encoding, or the encoding MODx/php uses to talk to MySQL isn’t correct.
The Website Encoding
Your MODx site’s character encoding can be configured in the manager under Tools/Configuration/Site/Character encoding. This is the encoding your website’s visitors will get.
The Manager’s Encoding
The manager’s encoding can be changed by setting $modx_manager_charset at manager/includes/lang/<language>.inc.php like this (for example):
$modx_manager_charset = 'iso-8859-1';
To find out what language you’re using (and thus was file you need to change), check Tools/Configuration/Site/Language (1 line above the character encoding setting).
This needs to be the same encoding as your site. You can’t have your manager in utf8 and your site in iso-8859-1.
Your Database’s Encoding
The charset MODx/php uses to talk to your database can be set by changing $database_connection_charset in manager/includes/config.inc.php. This needs to be the same as your database’s charset. Make sure you use the correct corresponding charset, for iso-8859-1 you need to use ‘latin1’. Utf8 is just utf8.
$database_connection_charset = 'latin1';
Now, if you check Reports/System info, the ‘Database Charset’ might say something else. This is because the mysql variable ‘character_set_database’ is displayed here, which contains the character set used by the default database and not the one for the current database/connection.
However, if you’d change this to display ‘character_set_connection’, it could still say something else because the ‘set character set’ statement used by MODx doesn’t change this value either. The ‘set names’ statement does, but since it turns out my MODx install works now as expected I’ll just leave it at this before I get a headache.
If I saved you a potential headache or you think I’m totally wrong or overlooked something, let me know in the comments.
btw: I want to be able to use a real editor with MODx. Somehow.
Leave a Reply