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--EXPECTF--
60Active code page: 65001
61filename: . : filetype: dir
62filename: .. : filetype: dir
63filename: Röd_Statistics.txt : filetype: file
64filename: tschüß : filetype: file
65filename: tschüß3 : filetype: dir
66filename: Voláçao : filetype: file
67filename: Voláçao3 : filetype: dir
68filename: českýtestování.inc : filetype: file
69filename: š.txt : filetype: file
70filename: żółć : filetype: dir
71filename: żółć.txt : filetype: file
72filename: Ελλάδα.txt : filetype: file
73filename: привет : filetype: file
74filename: привет3 : filetype: dir
75filename: テストマルチバイト・パス : filetype: file
76filename: テストマルチバイト・パス42 : filetype: dir
77filename: 測試多字節路徑 : filetype: file
78filename: 測試多字節路徑5 : filetype: dir
79Active code page: %d
80