Thursday, March 20, 2008

Repairing Zen-Cart's use of HTML Characters (umlauts, cyrillic, etc)

One of the bigger alterations i've made to the Zen-Cart code recently has been a large update of it's country and state zone files (so instead of users typing their state and city into text fields, they can select them from a drop-down box that only shows references for their particular country).

Unfortunately, in 1.3.7 and 1.3.8 -- the code for handling HTML entities is slightly broken, so users from Nordic or Germanic countries see:

Baden-Württemberg rather than Baden-Württemberg

In places like the Shipping Information or the Account Creation code.

The solution i've been using, is to edit the files that reference the zen_js_zone_list code and correctly sanitise the output-- this is done in two places (one for admin, one for userland).

Firstly, edit the admin/includes/functions/html_output.php file and around line 188 change:


--- return $output_string;
+++ return html_entity_decode($output_string);


Secondly, edit the includes/functions/functions_general.php file and around line 1448 change:


--- return $output_string;
+++ return html_entity_decode($output_string);


You should now have accented characters in places they should be.