xref: /PHP-8.0/ext/zip/tests/oo_add_encoding.phpt (revision 0c6d06ec)
1--TEST--
2ziparchive::addEmptyDir with encoding option
3--SKIPIF--
4<?php
5/* $Id$ */
6if(!extension_loaded('zip')) die('skip');
7?>
8--FILE--
9<?php
10
11include __DIR__ . '/utils.inc';
12$dirname = __DIR__ . '/oo_add_encoding_dir/';
13$file = $dirname . 'tmp.zip';
14
15@mkdir($dirname);
16$zip = new ZipArchive;
17if (!$zip->open($file, ZipArchive::CREATE)) {
18    exit('failed');
19}
20
21$zip->addEmptyDir('foo');
22$zip->addEmptyDir(chr(0x82), ZipArchive::FL_ENC_CP437);
23$zip->addEmptyDir('è', ZipArchive::FL_ENC_UTF_8);
24
25$zip->addFromString('bar', __FILE__);
26$zip->addFromString(chr(0x91), __FILE__, ZipArchive::FL_ENC_CP437);
27$zip->addFromString('€', __FILE__, ZipArchive::FL_ENC_UTF_8);
28
29if ($zip->status == ZIPARCHIVE::ER_OK) {
30    dump_entries_name($zip);
31    $zip->close();
32} else {
33    echo "failed\n";
34}
35?>
36--CLEAN--
37<?php
38$dirname = __DIR__ . '/oo_add_encoding_dir/';
39unlink($dirname . 'tmp.zip');
40rmdir($dirname);
41?>
42--EXPECT--
430 foo/
441 é/
452 è/
463 bar
474 æ
485 €
49