1--TEST--
2Test readdir() with a dir for multibyte filenames
3--SKIPIF--
4<?php
5include __DIR__ . DIRECTORY_SEPARATOR . "util.inc";
6
7skip_if_not_win();
8if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
9skip_if_no_required_exts();
10
11?>
12--CONFLICTS--
13mb_names
14--FILE--
15<?php
16
17include __DIR__ . DIRECTORY_SEPARATOR . "util.inc";
18
19$prefix = create_data("mb_names");
20$content = "";
21create_verify_file($prefix, "českýtestování.inc", $content);
22create_verify_file($prefix, "Röd_Statistics.txt", $content);
23create_verify_file($prefix, "š.txt", "");
24create_verify_file($prefix, "tschüß", $content);
25create_verify_file($prefix, "Voláçao", "hola");
26create_verify_file($prefix, "Ελλάδα.txt", "");
27create_verify_file($prefix, "привет", "opened an utf8 filename for reading");
28create_verify_file($prefix, "テストマルチバイト・パス", $content);
29create_verify_file($prefix, "測試多字節路徑", $content);
30create_verify_file($prefix, "żółć.txt", $content);
31create_verify_dir($prefix, "tschüß3");
32create_verify_dir($prefix, "Voláçao3");
33create_verify_dir($prefix, "привет3");
34create_verify_dir($prefix, "テストマルチバイト・パス42");
35create_verify_dir($prefix, "測試多字節路徑5");
36create_verify_dir($prefix, "żółć");
37
38
39$dirw = $prefix . DIRECTORY_SEPARATOR;
40
41$old_cp = get_active_cp();
42set_active_cp(65001);
43
44if (is_dir($dirw)) {
45    if ($dh = opendir($dirw)) {
46        while (($file = readdir($dh)) !== false) {
47            echo "filename: $file : filetype: " . filetype($dirw . $file) . "\n";
48        }
49        closedir($dh);
50    }
51} else {
52	echo "is_dir failed\n";
53}
54set_active_cp($old_cp);
55
56remove_data("mb_names");
57
58?>
59===DONE===
60--EXPECTF--
61Active code page: 65001
62filename: . : filetype: dir
63filename: .. : filetype: dir
64filename: Röd_Statistics.txt : filetype: file
65filename: tschüß : filetype: file
66filename: tschüß3 : filetype: dir
67filename: Voláçao : filetype: file
68filename: Voláçao3 : filetype: dir
69filename: českýtestování.inc : filetype: file
70filename: š.txt : filetype: file
71filename: żółć : filetype: dir
72filename: żółć.txt : filetype: file
73filename: Ελλάδα.txt : filetype: file
74filename: привет : filetype: file
75filename: привет3 : filetype: dir
76filename: テストマルチバイト・パス : filetype: file
77filename: テストマルチバイト・パス42 : filetype: dir
78filename: 測試多字節路徑 : filetype: file
79filename: 測試多字節路徑5 : filetype: dir
80Active code page: %d
81===DONE===
82