Typo3 and UTF-8 support
- June 22nd, 2010
- Posted in HTML . PHP . Typo3
- By Mr. Nerd
- Write comment
There are quite a few configuration options in Typo3 which come into play if you intend to run the system completely with UTF-8. And the mean thing is: If you sod up only one of them, chances are good that some things will work but others won’t.
So here’s a list of options I’m currently setting for UTF-8 support.
Settings in localconf.php
The following values need to be set in localconf.php, so you can just set them using the Typo3 install tool.
forceCharset
The value of this field is used by Typo internally for different configuration. You need to set it to UTF-8.
multiplyDBfieldSize
This value sets the size of characters as used in the database. Since in UTF-8, only one character is used, you need to set this to 1 (this is the default).
setDBinit
All statements placed within this value will be sent to the database server each time a new connection is opened. The following two lines should be sufficient to do the magic, if not, set the character_set_server as well:
SET NAMES utf8; SET CHARACTER SET utf8;
UTF8filesystem
With this field, you tell Typo that your filesystem supports UTF-8 filenames. This is quite important, otherwise Typo will place uploaded files with non-ASCII-characters under invalid names. Set to 1.
If you don’t like the install tool, here’s the PHP code to put into your localconf.php:
$TYPO3_CONF_VARS['SYS']['UTF8filesystem'] = '1'; $TYPO3_CONF_VARS['BE']['forceCharset'] = 'utf-8'; $TYPO3_CONF_VARS['SYS']['setDBinit'] = 'SET NAMES utf8;'.chr(10).'SET CHARACTER SET utf8;';
Settings in TypoScript
In order to have Typo deliver the page with a valid encoding head, you should also add the following statement in your template.
config{
additionalHeaders = Content-Type:text/html; charset=utf-8
metaCharset = utf-8
}
From now on, Typo will use UTF-8 as the default charset on all levels.