I’ve been struggling on and off with this problem for several weeks. I’ve now managed to produce a simple situation where the problem is reproduced. It only seems to happen with MODx.
Problem: Accented characters don’t seem to work properly in snippets
Severity: This is critical for development of non-english web sites
How to Reproduce:
1. Create a MySQL table called "test" with the following fields:
- id, int(11), unsigned, auto increment, primary
- name, text(200) (utf8)
2. Create a php file called "test.php":
<?php
function tok($string) {
$want = "Öffentlich";
return "(".$want.")";
}
?>
3. Create a snippet called Insert:
<?php
require_once "test.php";
$dbTable = array();
$dbTable['name'] = tok('foo');
$modx->db->insert($dbTable, 'test');
?>
4. Create a new document with just a call to the Insert snippet.
Load the page and look at the contents of the name field in the table. You will see:
Things to try:
1. Try editing the tok() function to use strcmp on the variable $want. It won’t match "Öffentlich". Weird.
2. Move the tok function into the snippet. Now it works!
I’m using 0.9.5 RC3, Linux (Gentoo 2006.1), PHP 5.1.6, MySQL 5.0.26.
I really hope someone can give me some clues or things to try before I pull my remaining hair out. I need to get this German based website done. :’(
Andy