The character encoding stuff seems a bit silly.
Everything gets encoded into html entities, which really shouldn’t be necessary since we use UTF-8 by default, and the database should be built to handle that in the first place. But then again, it might be prudent as some browsers can’t handle character sets correctly.
What isn’t prudent though, is to convert back from html entities when it becomes time to show the data. The browser does that prefectly ok, that’s what HTML-browsers are for, to parse HTML-data!
So, comment out (or delete) these lines:
line 1222:
// $value = html_entity_decode($value);
line 1326:
// $setting = html_entity_decode($setting);
and line 1758:
// $value = html_entity_decode($value);
Doing that will get rid of most problems with the encodings. You might also want to use the correct encoding when you save the data to the database, which means you need to find the places where data is saved. Do a search for "htmlentities" and change everyone of them along this pattern:
Original:
$generalElementsUpdate[] = " `".$field."` = '".$modx->db->escape(stripslashes(htmlentities(trim($_POST[$field]), ENT_QUOTES)))."'";
Corrected version:
$charset='"'.$modx->config['modx_charset'].'"';
$generalElementsUpdate[] = " `".$field."` = '".$modx->db->escape(stripslashes(htmlentities(trim($_POST[$field]), ENT_QUOTES,$charset)))."'";
That should do the trick.