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--EXPECT--
47Returned (a)
48Encoding: ASCII
49
50Returned (şŞıİğĞ)
51Encoding: UTF-8
52
53Returned (ソ)
54Encoding: UTF-8
55
56Returned (ゾ)
57Encoding: UTF-8
58
59Returned (多国語)
60Encoding: UTF-8
61
62Returned (汚れて掘る)
63Encoding: UTF-8
64
65Returned (王)
66Encoding: UTF-8
67
68