iconv 프로그램을 이용해서 utf8로 변환 (이거 설명좀 부탁 합니다.) 정보
iconv 프로그램을 이용해서 utf8로 변환 (이거 설명좀 부탁 합니다.)본문
저 같은 경우는 PHP를 쉘에서 실행(CLI라고 하죠) 하는 프로그래을 하나 짜서
해당 디렉토리를 읽어서 php 확장자가 걸린 화일을 iconv 프로그램을 이용해서 utf8로 변환합니다.
대략 프로그램으로 표현하면 아래와 같이 하시면 될듯합니다.
$input_dir = "./source";
$output_dir = "./result";
$input_encording = "euc-kr";
$output_encording = "utf-8";
if ($handle = opendir("$input_dir")) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && is_file($file)) {
echo "$file\n";
@exec("iconv -c -s -f $input_encording -t $output_encording $input_dir/$file > $output_dir/$file");
}
}
}
해당 디렉토리를 읽어서 php 확장자가 걸린 화일을 iconv 프로그램을 이용해서 utf8로 변환합니다.
대략 프로그램으로 표현하면 아래와 같이 하시면 될듯합니다.
$input_dir = "./source";
$output_dir = "./result";
$input_encording = "euc-kr";
$output_encording = "utf-8";
if ($handle = opendir("$input_dir")) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && is_file($file)) {
echo "$file\n";
@exec("iconv -c -s -f $input_encording -t $output_encording $input_dir/$file > $output_dir/$file");
}
}
}
댓글 전체
사용법을 몰라서요...
