1--TEST--
2Bug #54028 Directory::read() cannot handle non-unicode chars properly
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("mbstring");
10
11?>
12--FILE--
13<?php
14
15/* This file is in UTF-8. */
16
17include __DIR__ . DIRECTORY_SEPARATOR . "util.inc";
18
19$prefix = __DIR__ . DIRECTORY_SEPARATOR . "testBug54028" . DIRECTORY_SEPARATOR;
20
21$dirs = array("a", "ソ", "ゾ", "şŞıİğĞ", "多国語", "王", "汚れて掘る");
22
23mkdir($prefix);
24foreach ($dirs as $d) {
25	mkdir($prefix . $d);
26}
27
28$directory = dir($prefix);
29while (false !== ($content = $directory->read())) {
30	if ("." == $content || ".." == $content) continue;
31
32        printf("Returned (%s)\n", $content);
33        printf("Encoding: %s\n", mb_detect_encoding($content));
34        if ($content != get_basename_with_cp($prefix . $content, 65001, false)) {
35		echo "Verification failed!\n";
36	}
37	echo "\n";
38}
39
40foreach ($dirs as $d) {
41	rmdir($prefix . $d);
42}
43rmdir($prefix);
44
45?>
46===DONE===
47--EXPECT--
48Returned (a)
49Encoding: ASCII
50
51Returned (şŞıİğĞ)
52Encoding: UTF-8
53
54Returned (ソ)
55Encoding: UTF-8
56
57Returned (ゾ)
58Encoding: UTF-8
59
60Returned (多国語)
61Encoding: UTF-8
62
63Returned (汚れて掘る)
64Encoding: UTF-8
65
66Returned (王)
67Encoding: UTF-8
68
69===DONE===
70