[TYPO3-german] Umlautfehler in tt_news nach Charset-Wechsel.. Und nu?

Andreas Becker ab.becker at web.de
Wed Jun 6 20:08:55 CEST 2007


Hi Fabian

Eine weitere Moeglichkeit mit iconv zu konvertieren.
----------------------

iconv [-c] [-s] [-f encoding] [-t encoding] [inputfile ...] > [outputfile ...]
iconv -l

Ich hoffe Du verstehst genug English!

Description <file:///C:/Program%20Files/GnuWin32/man/html/iconv.1.html#toc2>The
*iconv* program converts text from one encoding to another encoding. More
precisely, it converts *from* the encoding given for the *-f* option
*to*the encoding given for the
*-t* option. Either of these encodings defaults to the encoding of the
current locale. All the *inputfile*s are read and converted in turn; if no *
inputfile* is given, the standard input is used. The converted text is
printed to standard output.

When option *-c* is given, characters that cannot be converted are silently
discarded, instead of leading to a conversion error.

When option *-s* is given, error messages about invalid or unconvertible
characters are omitted, but the actual converted text is unaffected.
------------------------------------------
Das Problem bei TYPO3 liegt jedoch woanders
lese hier weiter:
-----------------------------------------

typo3 sets incorrectly mysql tables at installation

I have installed typo3 (ver. 4.0.4. with php 5.1.6-5 [debian] and mysql
5.0.30-Debian_1-log) and only after some time I have realized that thought
utf-8 seem to work correctly everywhere, the instalation has set incorrectly
all collations of all db fields to default latin1_swedish_ci.

The result is that it is impossible to use the db in php connections which
are correctly set up [as utf-8]. The settings mentioned on this page
[particularly [setDBinit] String setting] sets the connection right, but
than all int. characters on front page are crippled.

The situation is that thought typo3 stores all text values in utf-8, but to
latin1 fields - so for example if you look at them in phpmyadmin they come
out incorrectly. If you want to correctly set up typo3 according to this
page you should alo convert whole database to utf8 somehow. The CONVERT TO
sql command is useless, because it tries to convert characters from latin1
to utf-8 so they finished "doubleencoded". The correct way to do it is to
convert all fields manually first to BINARY [which causes no conversion] and
than back to utf8. You can use this script for this:



<?php
if ($argc != 3 || !mysql_select_db($argv[1])) {
exit("Usage: php $argv[0] db collation\n");
}
$collation = $argv[2];
function mysql_convert($query)
{
//~ echo "$query;\n";
return mysql_query($query);
}
mysql_convert("ALTER DATABASE $argv[1] COLLATE $collation");
$result = mysql_query("SHOW TABLES");
while ($row = mysql_fetch_row($result)) {
mysql_convert("ALTER TABLE $row[0] COLLATE $collation");
$result1 = mysql_query("SHOW COLUMNS FROM $row[0]");
while ($row1 = mysql_fetch_assoc($result1)) {
if (preg_match('~char|text|enum|set~', $row1["Type"])) {
mysql_convert("ALTER TABLE $row[0] MODIFY $row1[Field] $row1[Type] CHARACTER
SET binary");
mysql_convert("ALTER TABLE $row[0] MODIFY $row1[Field] $row1[Type] COLLATE
$collation" .
($row1["Null"] ? "" : " NOT NULL") . ($row1["Default"] &&
$row1["Default"] != "NULL" ? " DEFAULT '$row1[Default]'" : ""));
}
}
}
mysql_free_result($result);
?>

this works from command line like that:

php convert.php dbase collation

also you might need to add st. like

mysql_connect("localhost","username","password");

at the beginning of the script.

The solution is translated from the Czech page
http://php.vrana.cz/prevod-kodovani-mysql.php Hope it helps.

Gruss
Andi




Am 07.06.07 schrieb Martin Holtz <typo3 at martinholtz.de>:
>
> Hi Fabian,
>
> > Nachdem ich mein System (nachtraeglich) von IS0-8859-1 auf utf-8
> > umgestellt habe, werden mir in meinen tt_news-Artikeln die Umlaute
> > falsch (bzw. als Fragezeichen) dargestellt.
> >
> > Was kann ich da tun?
> > Wie bekomme ich die Umlaute utf-8 passend,
> > ohne von Hand alle Eintraege bearbeiten zu muessen?
> Es gibt da eine Extension, die kann Seiteninhalte ändern.
>
> Allerdings soweit ich weiß nur Seiteninhalte.
>
> Die könntest Du so anpassen, dass die auch die News-Einträge ändert.
>
> Oder Du schaust Dir an, was die so macht und führst ggf. die SQL-Befehle
> von
> Hand aus.
>
> Was auch immer du tust: vorher ein BAckup machen!
>
> gruß,
> martin
>
> _______________________________________________
> TYPO3-german mailing list
> TYPO3-german at lists.netfielders.de
> http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-german
>


More information about the TYPO3-german mailing list