Trouble with Characters

Author: thorn (from the WB forum)

Definition: Charset and Collation

Below the definition of the terms charset and collation which will be used frequently in this section.

  • Charset: character set or the encoding of characters like latin1, cp1251, utf8, ....
  • Collation: defines the sort order for strings and other functions (e.g. latin1_swedish_ci, utf8_unicode_ci, ...). The collation is assigned to a certain charset. Hence the settings "latin1_swedish_ci" requires the charset "latin1" (if you set the collation via myphpadmin, the character-set will be set automatically)

Default settings (possible traps and solutions)

If you have problems with the right display of characters, you should try to upgrade to the last WB version available. From WB v2.6.6 onwards, on should set the following setting via the WB backend: Settings -> Show Advanced Options -> Charset -> uft-8. Other charsets should work as well, but stick to uft-8 to prevent possible problems. Even if the last WebsiteBaker version is installed, the following problems may occur.

Error 1: German umlauts or e.g. Cyrillic characters are displayed wrong

Reason #1: Missing charset in the template.

Check if the following lines are contained in the index.php file of your template:

<meta http-equiv="Content-Type" content="text/html; charset=<?php 
if(defined('DEFAULT_CHARSET')) { echo DEFAULT_CHARSET; } else 
{ echo 'utf-8'; }?>" />

Reason # 2: Apache sends PHP pages as ISO-8859-1

If you can exclude Reason #1, check the charset used by your browser. If the browser is set to a value other than utf-8 (e.g. ISO-8859-1) one should change the browser settings. If you want to force the browser to use uft-8 for all pages, place a .htaccess file in the WB root folder. This requires a Apache web server.

<Files .htaccess>
order allow,deny
deny from all
</Files>
php_value default_charset UTF-8

The statement above enforces the Apache web server to send all php generated pages with UTF-8 encoding.

Error 2: Some characters are displayed wrong

If you use Cyrillic, e.g. "И" and "ш" may be affected, for Greek e.g. "ή" may be displayed wrong.

Reason: Default-character-set is defined via my.ini or my.cnf or the user has choosen a certain character-set for the database

The default-characer-set can be changed by the MySQL files my.ini or my.cnf file. If no default-character-set is defined in those files, latin1 is used as default-character-set by MySQL. If you choose a character-set other than latin1 when creating the database (e.g. by myphpadmin), one needs to add this value as default-character-set. In other words, the character set used during the creation of the database must be identicall to the default-character-set and vice vera. If character-set of database and default-character-set are different, characters will be displayed wrong.

If your service provider defines a default-character-set other than latin1 by the use of my.ini, the following options exist.

  1. ask your service provider to change the setting to latin1
  2. character-set of WB database must be set to the default-character-set defined by your service provider

Note:
Option 2 requires you to create the WB database manually by the use of e.g. myphpadmin. It is not possible to use the installation routine of the WB installation wizard, as WB uses latin1 as default. You must ensure that the character-set of all DB tables and fields is set to the default-character-set.