Technical - Converting from iso-8859-1 to utf8

Modern sites should use UTF8 or UTF8MB4

Do I need to convert to UTF-8?

Since Zen Cart v1.5.0 all new sites install database tables with the UTF8 character-set. If your site is from an older version, your database might still be in latin1 mode due to the server’s master configuration. To change the database to utf8, use the instructions below.

Converting to UTF8:

1. Use this conversion utility to convert your data to UTF8 (AFTER MAKING AND TESTING A DATABASE BACKUP):
2. (If you installed your site NEW since v1.5.0 or newer, then the following are ALREADY done for you. But, if you UPGRADED from a version prior to 1.5.0, then you will need to double-check each of the following:)

  1. Edit /admin/includes/languages/english.php (and all other language_name.php files in that folder) and set the define for CHARSET to ‘utf-8’.
    Do the same with the non-admin /includes/languages/english.php (and other language_name.php files in that folder)
    … AND …
  2. Also edit your two configure.php files to set DB_CHARSET to ‘utf8’:
    define(‘DB_CHARSET’, ‘utf8’);
    (Remember, the configure.php files are most likely set to read-only on your server, so you’ll need to change their permissions on the server to be writable before you can save the changes you’re making.)
    (Remember, you must do this for both your /YOURADMIN/includes/configure.php and /includes/configure.php )

Ignoring UTF8 and using a different character set:

If you wish to stick with Latin1 (aka iso-8859-1) use the following steps. Note that there is no latin1 support in Zen Cart since v1.5.5.

If your site IS RUNNING or you have UPGRADED FROM an older version of Zen Cart where your language files are/were set to iso-8859-1, and if you don’t have any specific need for extended-character multibyte support (for example your store is only in english and only english-speaking customers visit your store), then you may find it best to keep your site in iso-8859-1 (aka “latin1”) mode instead of converting to UTF8.

To do this, you’ll need to fix BOTH your admin and non-admin files:

  1. Edit your upgraded english.php file to use the old CHARSET and setlocale settings (SEE YOUR OLD english.php FILE CONTENTS).
    That is, in both the admin and non-admin configure.php files, KEEP the old references to iso-8859-1 INSTEAD of utf-8. You can see these defines in your pre-upgrade english.php files.
    Same with any other whatever_language.php files.
    … AND …
  2. Also edit your two configure.php files to set DB_CHARSET to ‘latin1’ instead of ‘utf8’
    (add the line if it doesn’t exist):
    define(‘DB_CHARSET’, ‘latin1’);

Useful video about the history behind why UTF8 was created:

Still have questions? No problem! Just head over to the Zen Cart support forum and ask there in the appropriate subforum. In your post, please include your Zen Cart and PHP versions, and a link to your site.

Is there an error or omission on this page? Please post to General Questions on the support forum. Or, if you'd like to open a pull request, just review the guidelines and get started. You can even PR right here.
Last modified August 23, 2020 by Chris Brown (98b2da7).