Answer the question
In order to leave comments, you need to log in
PHP How to encode filenames with Cyrillic when extracting from a zip archive?
Guys, help me, for 2 days I've been trying to recode file names when extracting from a zip archive.
here is the code itself:
$zip = new ZipArchive();
$state = $zip->open('test.zip');
if ($state === true) {
for ($i = 0; $i < $zip->numFiles; ++$i) {
//skip if folder
$stats = $zip->statIndex($i);
if ($stats['size'] === 0 && $stats['crc'] === 0) {
continue;
}
$name = $zip->getNameIndex($i);
$content = $zip->getFromIndex($i);
}
$zip->close();
}
unset($zip);
䫬π0¼Ñ¡Γᵿ∩ ¬ Γ«αúá¼ Çαßᬿ ŽÑσá¡δ
LC_COLLATE=C;LC_CTYPE=Russian_Russia.1251;LC_MONETARY=C;LC_NUMERIC=C;LC_TIME=C
LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=C;LC_COLLATE=C;LC_MONETARY=C;LC_MESSAGES=C;LC_PAPER=C;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=C;LC_IDENTIFICATION= C
Answer the question
In order to leave comments, you need to log in
Partially managed to get the 1st result with such a perversion:
$name = iconv('UTF-8', 'cp1252//IGNORE', $zip->getNameIndex($i));
$name = iconv('cp1252', 'cp850//IGNORE', $name);
$name = iconv('cp866','UTF-8//IGNORE',$name);
Documentation to the ogs of Asaki Plean/Ak deekatsii.pdf
Documentation for the auction Arsaki Plekhany/Defective act.pdf
$name = iconv('UTF-8', 'cp437//IGNORE', $zip->getNameIndex($i));
$name = iconv('cp437', 'cp865//IGNORE', $name);
$name = iconv('cp866','UTF-8//IGNORE',$name);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question