Skip to content

Commit 3933fc6

Browse files
committed
ignore utf-8 chars that don't fit into CP437
1 parent a72a6e5 commit 3933fc6

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

src/Zip.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ protected function cpToUtf8($string)
654654
protected function utf8ToCp($string)
655655
{
656656
if (function_exists('iconv')) {
657-
return iconv('UTF-8', 'CP437', $string);
657+
return iconv('UTF-8', 'CP437//IGNORE', $string);
658658
} elseif (function_exists('mb_convert_encoding')) {
659659
return mb_convert_encoding($string, 'CP850', 'UTF-8');
660660
} else {
@@ -863,7 +863,7 @@ protected function encodeFilename($original)
863863
1, // version
864864
crc32($original) // crc
865865
);
866-
$extra.= $original;
866+
$extra .= $original;
867867

868868
return array($cp437, $extra);
869869
}

tests/zip.test.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ public function test_utf8() {
162162
$zip = new Zip();
163163
$zip->create($archive);
164164
$zip->addData('tüst.txt', 'test');
165+
$zip->addData('snowy☃.txt', 'test');
165166
$zip->close();
166167
$this->assertFileExists($archive);
167168

@@ -170,6 +171,7 @@ public function test_utf8() {
170171
$zip->extract($extract);
171172

172173
$this->assertFileExists($extract.'/tüst.txt');
174+
$this->assertFileExists($extract.'/snowy☃.txt');
173175

174176
$this->nativeCheck($archive);
175177
$this->native7ZipCheck($archive);

0 commit comments

Comments
 (0)