1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
<?php
$dh = @opendir('.'); if (!$dh) { die('Failure'); }
// Only non-UTF languages! $ext = array( 'tw' => 'big5', 'se' => 'ISO-8859-1', 'pt_PT' => 'ISO-8859-1', 'pt' => 'ISO-8859-1', 'no' => 'ISO-8859-1', 'nl' => 'ISO-8859-1', 'it' => 'ISO-8859-1', 'is' => 'ISO-8859-1', 'hu' => 'ISO-8859-2', 'fr' => 'ISO-8859-1', 'es' => 'ISO-8859-15', 'en' => 'ISO-8859-1', 'de' => 'ISO-8859-1', 'da' => 'ISO-8859-1', 'cz' => 'ISO-8859-2', 'cs' => 'windows-1250', 'bg' => 'windows-1251', 'zh' => 'gb2312' );
while (($file = readdir($dh)) !== false) { if (!preg_match('@lang_(.+)\.inc\.php$@i', $file, $extmatch)) { continue; } if (!isset($ext[$extmatch[1]])) { echo "'$file' already is in UTF-8. Leaving untouched.\n"; } else { $set = $ext[$extmatch[1]]; $cmd = 'iconv -f ' . $set . ' -t UTF-8 -o ' . $file . '.new ' . $file . "\n"; echo $cmd; $return = `$cmd`; chmod($file, 0644); $fc = file_get_contents($file . '.new'); $fc = preg_replace('@' . $set . '@i', 'UTF-8', $fc); $fp = fopen($file, 'w'); fwrite($fp, $fc); fclose($fp); unlink($file . '.new'); } }
closedir($dh);
|