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"); 8?> 9--FILE-- 10<?php 11include('encoding_tests.inc'); 12 13srand(1000); // Make results consistent 14mb_substitute_character(0x25); // '%' 15readConversionTable(__DIR__ . '/data/EUC-TW.txt', $toUnicode, $fromUnicode); 16 17findInvalidChars($toUnicode, $invalid, $truncated); 18testAllValidChars($toUnicode, 'EUC-TW', 'UTF-16BE', false); 19testAllValidChars($fromUnicode, 'UTF-16BE', 'EUC-TW', false); 20testAllInvalidChars($invalid, $toUnicode, 'EUC-TW', 'UTF-16BE', "\x00%"); 21testTruncatedChars($truncated, 'EUC-TW', 'UTF-16BE', "\x00%"); 22echo "Tested EUC-TW -> UTF-16BE\n"; 23 24findInvalidChars($fromUnicode, $invalid, $unused, array_fill_keys(range(0,0xFF), 2)); 25convertAllInvalidChars($invalid, $fromUnicode, 'UTF-16BE', 'EUC-TW', '%'); 26echo "Tested UTF-16BE -> EUC-TW\n"; 27 28// Test "long" illegal character markers 29mb_substitute_character("long"); 30convertInvalidString("\x80", "%", "EUC-TW", "UTF-8"); 31convertInvalidString("\x8E\x20", "%", "EUC-TW", "UTF-8"); 32convertInvalidString("\x8E\xA1\x20", "%", "EUC-TW", "UTF-8"); 33convertInvalidString("\x8E\xA1\xA1\x20", "%", "EUC-TW", "UTF-8"); 34convertInvalidString("\x8E\xA2\xA3\x20", "%", "EUC-TW", "UTF-8"); 35convertInvalidString("\x8F", "%", "EUC-TW", "UTF-8"); 36convertInvalidString("\xA1\x50", "%", "EUC-TW", "UTF-8"); 37convertInvalidString("\xFD\xCC", "%", "EUC-TW", "UTF-8"); 38 39echo "Done!\n"; 40?> 41--EXPECT-- 42Tested EUC-TW -> UTF-16BE 43Tested UTF-16BE -> EUC-TW 44Done! 45