Jeder haben einen schönen Trick, wie man eine Reihe von PHP-und HTML-Dateien von UTF-8 zu ISO-8859-1 in Linux (Ubuntu) zu konvertieren?Konvertieren von Webseiten von UTF-8 nach ISO-8859-1 in Linux
9
A
Antwort
19
Ubuntu hat recode
$ sudo apt-get install recode
$ recode UTF-8..latin1 *.php
Recursively dank Ted Dziuba:
$ find . -name "*.php" -exec recode UTF-8..latin1 {} \;
9
Ich denke, iconv ist Ihre Antwort ...
Formular Mann iconv:
NAME iconv - Convert encoding of given files from one encoding to another SYNOPSIS iconv -f encoding -t encoding inputfile DESCRIPTION The iconv program converts the encoding of characters in inputfile from one coded character set to another. The result is written to standard output unless otherwise specified by the --output option. .....
So könnte man wahrscheinlich tun ein
find $my_base_dir -name "*.php" -o -name "*.html" -exec sh -c "(\
iconv -t ISO88592 -f UTF8 {} -o {}.iconv ; \
mv {}.iconv {} ; \
)" \;
Dies wird die entsprechend benannten Dateien rekursiv finden und re-encode sie (die temporäre Datei ist notwendig, da iconv die Ausgabe abschneiden wird, bevor mit der Arbeit begonnen wird).
Recode ist ein ziemlich Standard-Linux-Programm - nicht so Standard, dass es immer standardmäßig installiert ist, aber es sollte auf verfügbar sein alle Distributionen, nicht nur Ubuntu. –
Wie kann ich das rekursiv tun? – Svish
Rekursiv, es ist zu finden. -name "* .php" -exec recode UTF-8..latin1 {} \; –