I use PHP ZipArchive class to extract a .zip file, It works fine for English, but cause problems in my local language (THAI).
I use icov('utf-8','windows-874',$zip->getNameIndex($i))
to convert utf-8 to THAI. It works for folder's/file's name, but doesn't work for extracted .zip file and cause this error :
iconv(): Detected an illegal character in input string
Can anyone please tell me what the problem is here?
My PHP code
$file = iconv('utf-8', 'windows-874', $_GET['File']);
$path = iconv('utf-8', 'windows-874', $_GET['Path']);
$zip = new ZipArchive;
if ($zip->open($file) === TRUE) {
// convert to Thai language
for($i = 0; $i < $zip->numFiles; $i++) {
$name = $zip->getNameIndex($i);
//echo iconv("charset zip file", "windows-874", $name);
//$zip->extractTo($path,$name); -> this problem
}
$zip->close();
echo json_encode('unZip!!!');
} else {
echo json_encode('Failed');
}
After I extract the zipped file, The file's name is not the one I set for it.
This is name i try to set :
Here is my zipped file :
https://www.dropbox.com/s/9f4j04lkvsyuy63/test.zip?dl=0
UPDATE
I tried unzipping the file in windows XP, it works fine there but not in windows 7.
utf8
anyway? What is the need to convert it towindows-874
? – Scupper