1--TEST--
2Test verification and conversion of UCS-4 text
3--EXTENSIONS--
4mbstring
5--FILE--
6<?php
7include('encoding_tests.inc');
8mb_substitute_character(0x25);
9
10testValidString("\xFF\xFE\x00\x00\x00\x30\x00\x00", "\x30\x00", "UCS-4", "UTF-16BE", false);
11testValidString("\x00\x00\xFE\xFF\x00\x00\x30\x01", "\x30\x01", "UCS-4", "UTF-16BE", false);
12testValidString("\x02\x30\x00\x00", "\x30\x02", "UCS-4LE", "UTF-16BE");
13testValidString("\x00\x00\x30\x03", "\x30\x03", "UCS-4BE", "UTF-16BE");
14
15// Truncated input
16convertInvalidString("\x01\x02\x03", "%", "UCS-4", "UTF-8");
17
18
19// Codepoint above U+10FFFF
20convertInvalidString("\x00\x11\x00\x00", "%", "UCS-4BE", "UTF-8");
21convertInvalidString("\x00\x00\x11\x00", "%", "UCS-4LE", "UTF-8");
22
23// Test "long" illegal character markers
24mb_substitute_character("long");
25convertInvalidString("\x6F\x00\x00\x00", "U+6F000000", "UCS-4BE", "UTF-8");
26convertInvalidString("\x70\x00\x00\x00", "U+70000000", "UCS-4BE", "UTF-8");
27convertInvalidString("\x78\x00\x00\x01", "U+78000001", "UCS-4BE", "UTF-8");
28convertInvalidString("\x80\x01\x02\x03", "U+80010203", "UCS-4BE", "UTF-8");
29convertInvalidString("\x00\x01\x02", "%", "UCS-4BE", "UTF-8");
30
31convertInvalidString("\x00\x00\x00\x6F", "U+6F000000", "UCS-4LE", "UTF-8");
32convertInvalidString("\x00\x00\x00\x70", "U+70000000", "UCS-4LE", "UTF-8");
33convertInvalidString("\x01\x00\x00\x78", "U+78000001", "UCS-4LE", "UTF-8");
34convertInvalidString("\x02\x01\x00", "%", "UCS-4LE", "UTF-8");
35
36echo "Done!";
37?>
38--EXPECT--
39Done!
40