Setting up TYPO3 and the Server for UTF-8 Mode

Setup of  TYPO3 with UTF-8 isn't quiet easy; not only because it's a bit tricky but there exist a lot of factoids about details in technical Forums and even in the offical bugtracker.

Here you can read the settings I  made to succeed:

  1. To store signs in UTF-8 naturally we have to input them, therefore we have to configure TYPO3 to treat them as UTF-8. So we assign following values inside localconf.php to the mentioned variables:

    $TYPO3_CONF_VARS['BE']['forceCharset'] = 'utf-8';
    $TYPO3_CONF_VARS['SYS']['setDBinit'] = 'SET NAMES utf8'.chr(10).'SET character_set_connection = utf8';
    $TYPO3_CONF_VARS['SYS']['UTF8filesystem'] = 1;

    It's also possible to go that step by the install-tool. Just search for the left standing expressions and insert the assigned values into the corresponding formularfields:

    ['BE']['forceCharset'] = utf-8
    ['SYS']['setDBinit'] = SET NAMES utf8; [-LINE BREAK-] SET character_set_connection = utf8';
    ['SYS']['UTF8filesystem'] = 1

  2. For transmitting the signs in the right manner by PHP to the database we insert or change the the following values inside php.ini (division [mbstring] ):

    default_charset = "UTF-8"
    mbstring.internal_encoding = UTF-8
    mbstring.http_input = UTF-8
    mbstring.http_output = UTF-8

  3. Now we can deliver the signs to MySQL which just needs some devices how to treat them. Put following lines inside my.ini, the configuration-file of MySQL:

    character-set-server = utf8
    collation-server = utf8_unicode_ci

    If it's possible do this step before you insert any values in the database otherwise some tables have to be converted and are useless for the moment.

  4. When you have changed all the values while the server was running restart it so that the new values take effect.

  5. With TypoScript devices now you can influence the page output. Without any devices I remarked that german pages are output with ISO-charset but you also can force TYPO3 to UTF-8 when you insert the following line into the TypoScript-template:

    config.metaCharset = utf-8

    With conditions - like usually needed for language specific settings inside TYPO3 - you can assign another charset to every language. The signs then are converted inside TYPO3.

Note:
The Option "SET character_set_connection = utf8" in $TYPO3_CONF_VARS['SYS']['setDBinit'] I added later. Normal Rendering works without this Option, but Data in the Cache-Table aren't saved as UTF-8.

The following Page is a deeper explanation how to setup the server and TYPO3 for UTF-8: http://wiki.typo3.org/wiki/UTF-8_support