1--TEST--
2Test of oddball text encodings which are not tested elsewhere
3--EXTENSIONS--
4mbstring
5--SKIPIF--
6<?php
7if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
8?>
9--FILE--
10<?php
11mb_substitute_character(0x25);
12
13// "7bit". This is not a real text encoding.
14var_dump(mb_convert_encoding("ABC", "7bit", "ASCII"));
15var_dump(mb_convert_encoding("\x80", "7bit", "ASCII"));
16var_dump(mb_convert_encoding("ABC", "8bit", "7bit"));
17var_dump(mb_check_encoding(chr(255), '7bit'));
18echo "7bit done\n";
19
20// "8bit"
21var_dump(mb_convert_encoding("\x01\x00", "8bit", "UTF-16BE")); // codepoints over 0xFF are illegal for '8-bit'
22echo "8bit done\n";
23
24// UCS-2
25echo bin2hex(mb_convert_encoding("\xFF\xFE\x00\x30", "UTF-16BE", "UCS-2")), "\n";
26echo bin2hex(mb_convert_encoding("\xFE\xFF\x30\x00", "UTF-16BE", "UCS-2")), "\n";
27echo bin2hex(mb_convert_encoding("\x00\x30", "UTF-16BE", "UCS-2LE")), "\n";
28echo "UCS-2 done\n";
29
30// UCS-4
31echo bin2hex(mb_convert_encoding("\xFF\xFE\x00\x00\x00\x30\x00\x00", "UTF-16BE", "UCS-4")), "\n";
32echo bin2hex(mb_convert_encoding("\x00\x00\xFE\xFF\x00\x00\x30\x01", "UTF-16BE", "UCS-4")), "\n";
33echo bin2hex(mb_convert_encoding("\x02\x30\x00\x00", "UTF-16BE", "UCS-4LE")), "\n";
34echo bin2hex(mb_convert_encoding("\x00\x00\x30\x03", "UTF-16BE", "UCS-4BE")), "\n";
35
36mb_substitute_character("long");
37echo mb_convert_encoding("\x01\x02\x03", "UTF-8", "UCS-4"), "\n";
38echo "UCS-4 done\n";
39
40?>
41--EXPECT--
42string(3) "ABC"
43string(1) "%"
44string(3) "ABC"
45bool(false)
467bit done
47string(1) "%"
488bit done
493000
503000
513000
52UCS-2 done
533000
543001
553002
563003
57%
58UCS-4 done
59