[TYPO3-dev] how to set the charset correctly to UTF-8

Stefan Neufeind typo3.neufeind at speedpartner.de
Wed Jan 4 21:10:39 CET 2012


On 01/04/2012 09:00 PM, Franz Holzinger wrote:
> Hello,
> 
> I have a problem on one site.
> I have successfully executed the script
> http://wiki.typo3.org/UTF-8_support#Convert_an_already_existing_database_to_UTF-8
> 
> by Jigal van Hemert.
> All characters are shown correctly with phpMyAdmin. The database, the
> tables and the tables fields are all set to 'utf8_general_ci'.
> php.ini:
> default_charset = "utf-8"
> 
> TYPO3 4.6.3
> PHP 5.3.2
> mysql  Ver 14.14 Distrib 5.1.41

[...]

Hi,

after successful conversion don't set forceCharset or setDBinit at all
(remove/comment that line from the config). Leaving it as an empty
string will prevent TYPO3 from performing its initialisation needed.

Install "sm_charsethelper" to confirm using the "Reports"-section that
your connection to the DB correctly uses UTF-8. And be sure to clear the
cache for up-to-date results in the frontend.

In case you can use a console maybe consider writing back your 4.4.x-db
(latin1), do all upgrade-steps in the installer, use the script below to
convert and remove both settings mentioned above from localconf.php.

Hope that helps,
 Stefan



#!/bin/bash
echo "needed parameters are: username dbname"
echo "will convert with user \"$1\" and DB \"$2\""
echo "press enter to continue"
read

# script according to
http://wiki.typo3.org/UTF-8_support#convert_databases_to_utf8
echo "ALTER DATABASE $2 CHARACTER SET utf8 COLLATE utf8_general_ci;" |
mysql -u $1 -p
mysqldump -u $1 -p --default-character-set=latin1 --databases $2 >
$2.orig.sql
cp $2.orig.sql $2.temp.sql
sed -i 's/DEFAULT CHARSET=latin1/DEFAULT CHARSET=utf8/g' $2.temp.sql
sed -i 's/CHARACTER SET latin1/CHARACTER SET utf8/g' $2.temp.sql
#sed -i 's/ENGINE=MyISAM/ENGINE=InnoDb/g' $2.new.sql

grep -v character_set_client <$2.temp.sql > $2.new.sql
rm $2.temp.sql
mysql -u $1 -p --default-character-set=utf8 $2 < $2.new.sql

# store just in case we might need them if something goes wrong
gzip $2.orig.sql
gzip $2.new.sql



More information about the TYPO3-dev mailing list