1--TEST--
2Bug #75063 Many filesystem-related functions do not work with multibyte file names, UTF-8
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--FILE--
13<?php
14
15/* This file is in UTF-8. */
16
17include __DIR__ . DIRECTORY_SEPARATOR . "util.inc";
18
19$dir_basename = "тест";
20$prefix = __DIR__ . DIRECTORY_SEPARATOR . "bug75063-utf8";
21$d0 = $prefix . DIRECTORY_SEPARATOR . $dir_basename;
22
23mkdir($prefix);
24create_verify_dir($prefix, $dir_basename);
25
26var_dump(get_basename_with_cp($d0, 65001, false));
27
28$old_cwd = getcwd();
29var_dump(chdir($d0));
30
31$code = <<<CODE
32<?php
33
34foreach(["test", "таст"] as \$fn) {
35	file_put_contents("\$fn.txt", "");
36}
37
38var_dump(getcwd());
39if (\$dh = opendir(getcwd())) {
40	while ((\$file = readdir(\$dh)) !== false) {
41		if ("." == \$file || ".." == \$file) continue;
42		var_dump(\$file);
43	}
44	closedir(\$dh);
45}
46CODE;
47$code_fn = "code.php";
48file_put_contents($code_fn, $code);
49
50print(shell_exec(getenv('TEST_PHP_EXECUTABLE') . " -nf code.php"));
51
52chdir($old_cwd);
53
54?>
55===DONE===
56--CLEAN--
57<?php
58$dir_basename = "тест";
59$prefix = __DIR__ . DIRECTORY_SEPARATOR . "bug75063-utf8";
60$d0 = $prefix . DIRECTORY_SEPARATOR . $dir_basename;
61
62$obj = scandir($d0);
63foreach ($obj as $file) {
64	if ("." == $file || ".." == $file) continue;
65	unlink($d0 . DIRECTORY_SEPARATOR . $file);
66}
67
68rmdir($d0);
69rmdir($prefix);
70
71?>
72--EXPECTF--
73string(8) "тест"
74bool(true)
75string(%d) "%sbug75063-utf8%eтест"
76string(8) "code.php"
77string(8) "test.txt"
78string(12) "таст.txt"
79===DONE===
80