/euckr2utf8.php
<?php
$f = $_SERVER['argv'][1];
if(!file_exists($f)) {
echo $f." file not found.\n";
}
$text = file_get_contents($f);
$text8 = @iconv('CP949', 'UTF-8//IGNORE', $text);
$cnt = strlen($text);
$cnt8 = strlen($text8);
if($cnt <= $cnt8) {
// 제대로 변경이 되었다면 용량이 커졌을 것이다.
// 용량이 같다면 한글이 없는 것이다.
rename($f, $f.'.euckr'); // 백업
file_put_contents($f, preg_replace('/charset=euc-kr/i', 'charset=utf-8', $text8));
echo $f." file is converted.\n";
} else {
// 용량이 작아진다면 잘못된 것이다.
$fp = fopen('/error.txt', 'a');
fwrite($fp, $f."\n");
fclose($fp);
}
?>
find ./public_html -type f -name "*.php" -exec php ../euckr2utf8.php "{}" \;
find ./public_html -type f -name "*.php3" -exec php ../euckr2utf8.php "{}" \;
find ./public_html -type f -name "*.htm" -exec php ../euckr2utf8.php "{}" \;
find ./public_html -type f -name "*.html" -exec php ../euckr2utf8.php "{}" \;
find ./public_html -type f -name "*.inc" -exec php ../euckr2utf8.php "{}" \;
find ./public_html -type f -name "*.js" -exec php ../euckr2utf8.php "{}" \;
find ./public_html -type f -name "*.txt" -exec php ../euckr2utf8.php "{}" \;
find ./public_html -type f -name "*.css" -exec php ../euckr2utf8.php "{}" \;
<?php
$f = $_SERVER['argv'][1];
if(!file_exists($f)) {
echo $f." file not found.\n";
}
$text = file_get_contents($f);
$text8 = @iconv('CP949', 'UTF-8//IGNORE', $text);
$cnt = strlen($text);
$cnt8 = strlen($text8);
if($cnt <= $cnt8) {
// 제대로 변경이 되었다면 용량이 커졌을 것이다.
// 용량이 같다면 한글이 없는 것이다.
rename($f, $f.'.euckr'); // 백업
file_put_contents($f, preg_replace('/charset=euc-kr/i', 'charset=utf-8', $text8));
echo $f." file is converted.\n";
} else {
// 용량이 작아진다면 잘못된 것이다.
$fp = fopen('/error.txt', 'a');
fwrite($fp, $f."\n");
fclose($fp);
}
?>
find ./public_html -type f -name "*.php" -exec php ../euckr2utf8.php "{}" \;
find ./public_html -type f -name "*.php3" -exec php ../euckr2utf8.php "{}" \;
find ./public_html -type f -name "*.htm" -exec php ../euckr2utf8.php "{}" \;
find ./public_html -type f -name "*.html" -exec php ../euckr2utf8.php "{}" \;
find ./public_html -type f -name "*.inc" -exec php ../euckr2utf8.php "{}" \;
find ./public_html -type f -name "*.js" -exec php ../euckr2utf8.php "{}" \;
find ./public_html -type f -name "*.txt" -exec php ../euckr2utf8.php "{}" \;
find ./public_html -type f -name "*.css" -exec php ../euckr2utf8.php "{}" \;
'Linux' 카테고리의 다른 글
한글파일명 (euckr) > (utf8)로 변경 (0) | 2009.05.20 |
---|---|
OS 문자셋 utf-8 로 변경하기 (0) | 2009.05.20 |
사용자 권한으로 실행하기 (0) | 2009.05.20 |
예약관리(클론) (0) | 2009.05.20 |
df 와 du의 용량이 다를경우 (1) | 2009.05.19 |