2009-03-27 9 views

答えて

19

Ubuntuはrecode

$ sudo apt-get install recode 
$ recode UTF-8..latin1 *.php 

を再帰的に、Ted Dziubaのおかげであります。

$ find . -name "*.php" -exec recode UTF-8..latin1 {} \; 
+1

が再符号化は、かなり標準的なLinuxのプログラムである - それは常にデフォルトでインストールされていますように、標準的ではないが、それは上で利用可能であるべきであるがUbuntuだけでなく、すべてのディストリビューション。 –

+0

これを再帰的に行うにはどうすればよいですか? – Svish

+0

再帰的に検索されます。 -name "* .php" -exec recode UTF-8..latin1 {} \; –

9

私はiconvのは、あなたの答えだと思う...

フォームの男の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. 

     ..... 

だから、あなたはおそらく

find $my_base_dir -name "*.php" -o -name "*.html" -exec sh -c "(\ 
    iconv -t ISO88592 -f UTF8 {} -o {}.iconv ; \ 
    mv {}.iconv {} ; \ 
)" \; 

を行うことができます。これは、再帰的に適切な名前のファイルを検索し、それらを再エンコードします(一時ファイルが必要です。iconvは作業を開始する前に出力を切り捨てます)。

関連する問題