1--TEST--
2Exhaustive test of verification and conversion of EUC-TW text
3--EXTENSIONS--
4mbstring
5--SKIPIF--
6<?php
7if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
8if (PHP_INT_SIZE == 4 && !extension_loaded("ctype")) die("skip needs ctype extension on 32-bit");
9?>
10--FILE--
11<?php
12include('encoding_tests.inc');
13
14srand(1000); // Make results consistent
15mb_substitute_character(0x25); // '%'
16readConversionTable(__DIR__ . '/data/EUC-TW.txt', $toUnicode, $fromUnicode);
17
18findInvalidChars($toUnicode, $invalid, $truncated);
19testAllValidChars($toUnicode, 'EUC-TW', 'UTF-16BE', false);
20testAllValidChars($fromUnicode, 'UTF-16BE', 'EUC-TW', false);
21testAllInvalidChars($invalid, $toUnicode, 'EUC-TW', 'UTF-16BE', "\x00%");
22testTruncatedChars($truncated, 'EUC-TW', 'UTF-16BE', "\x00%");
23echo "Tested EUC-TW -> UTF-16BE\n";
24
25findInvalidChars($fromUnicode, $invalid, $unused, array_fill_keys(range(0,0xFF), 2));
26convertAllInvalidChars($invalid, $fromUnicode, 'UTF-16BE', 'EUC-TW', '%');
27echo "Tested UTF-16BE -> EUC-TW\n";
28
29// Test "long" illegal character markers
30mb_substitute_character("long");
31convertInvalidString("\x80", "%", "EUC-TW", "UTF-8");
32convertInvalidString("\x8E\x20", "%", "EUC-TW", "UTF-8");
33convertInvalidString("\x8E\xA1\x20", "%", "EUC-TW", "UTF-8");
34convertInvalidString("\x8E\xA1\xA1\x20", "%", "EUC-TW", "UTF-8");
35convertInvalidString("\x8E\xA2\xA3\x20", "%", "EUC-TW", "UTF-8");
36convertInvalidString("\x8F", "%", "EUC-TW", "UTF-8");
37convertInvalidString("\xA1\x50", "%", "EUC-TW", "UTF-8");
38convertInvalidString("\xFD\xCC", "%", "EUC-TW", "UTF-8");
39
40echo "Done!\n";
41?>
42--EXPECT--
43Tested EUC-TW -> UTF-16BE
44Tested UTF-16BE -> EUC-TW
45Done!
46