armscii8_encoding.phpt 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. --TEST--
  2. Exhaustive test of verification and conversion of ARMSCII-8 text
  3. --EXTENSIONS--
  4. mbstring
  5. --SKIPIF--
  6. <?php
  7. if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
  8. ?>
  9. --FILE--
  10. <?php
  11. include('encoding_tests.inc');
  12. srand(111); // Make results consistent
  13. mb_substitute_character(0x25); // '%'
  14. readConversionTable(__DIR__ . '/data/ARMSCII-8.txt', $toUnicode, $fromUnicode);
  15. $irreversible = ["\x28", "\x29", "\x2C", "\x2D", "\x2E"];
  16. findInvalidChars($toUnicode, $invalid, $truncated);
  17. testAllValidChars($toUnicode, 'ARMSCII-8', 'UTF-16BE', false);
  18. foreach ($irreversible as $char)
  19. unset($toUnicode[$char]);
  20. testAllValidChars($toUnicode, 'ARMSCII-8', 'UTF-16BE');
  21. testAllInvalidChars($invalid, $toUnicode, 'ARMSCII-8', 'UTF-16BE', "\x00%");
  22. testTruncatedChars($truncated, 'ARMSCII-8', 'UTF-16BE', "\x00%");
  23. echo "Tested ARMSCII-8 -> UTF-16BE\n";
  24. findInvalidChars($fromUnicode, $invalid, $unused, array_fill_keys(range(0,0xFF), 2));
  25. convertAllInvalidChars($invalid, $fromUnicode, 'UTF-16BE', 'ARMSCII-8', '%');
  26. echo "Tested UTF-16BE -> ARMSCII-8\n";
  27. // Test "long" illegal character markers
  28. mb_substitute_character("long");
  29. convertInvalidString("\xA1", "%", "ARMSCII-8", "UTF-8");
  30. convertInvalidString("\xFF", "%", "ARMSCII-8", "UTF-8");
  31. echo "Done!\n";
  32. ?>
  33. --EXPECT--
  34. Tested ARMSCII-8 -> UTF-16BE
  35. Tested UTF-16BE -> ARMSCII-8
  36. Done!