htmlentities23.phpt 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. --TEST--
  2. htmlentities() / htmlspecialchars() ENT_SUBSTITUTE EUC-JP
  3. --FILE--
  4. <?php
  5. $tests = array(
  6. "\x8F\xA1\xFF", //2 sub as 2nd is potentially valid as lead
  7. "\x8F\xA1", //2 sub, as 2nd is potentially valid as lead
  8. "\x8F", //1 sub
  9. "\x8F\xA0", //1 sub, A0 is not valid as sole/first byte
  10. "\x8F\xA1\x21", //2 sub, no consume last
  11. "\x8F\x21", //1 sub, no consume last
  12. "\x8E\xAE", //valid
  13. "\x8E", //1 sub
  14. "\x8E\x21", //1 sub, no consume last
  15. "\xB2\xFF", //1 sub
  16. "\xB2", //1 sub
  17. "\xB2\x21", //1 sub, no consume last
  18. "\xA0", //1 sub
  19. );
  20. foreach ($tests as $test) {
  21. $a = htmlentities($test, ENT_QUOTES | ENT_SUBSTITUTE, "EUC-JP");
  22. var_dump($a, bin2hex($a));
  23. $a = htmlspecialchars($test, ENT_QUOTES | ENT_SUBSTITUTE, "EUC-JP");
  24. var_dump($a, bin2hex($a));
  25. echo "\n";
  26. }
  27. ?>
  28. --EXPECTF--
  29. Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
  30. string(16) "&#xFFFD;&#xFFFD;"
  31. string(32) "262378464646443b262378464646443b"
  32. string(16) "&#xFFFD;&#xFFFD;"
  33. string(32) "262378464646443b262378464646443b"
  34. Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
  35. string(16) "&#xFFFD;&#xFFFD;"
  36. string(32) "262378464646443b262378464646443b"
  37. string(16) "&#xFFFD;&#xFFFD;"
  38. string(32) "262378464646443b262378464646443b"
  39. Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
  40. string(8) "&#xFFFD;"
  41. string(16) "262378464646443b"
  42. string(8) "&#xFFFD;"
  43. string(16) "262378464646443b"
  44. Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
  45. string(8) "&#xFFFD;"
  46. string(16) "262378464646443b"
  47. string(8) "&#xFFFD;"
  48. string(16) "262378464646443b"
  49. Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
  50. string(17) "&#xFFFD;&#xFFFD;!"
  51. string(34) "262378464646443b262378464646443b21"
  52. string(17) "&#xFFFD;&#xFFFD;!"
  53. string(34) "262378464646443b262378464646443b21"
  54. Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
  55. string(9) "&#xFFFD;!"
  56. string(18) "262378464646443b21"
  57. string(9) "&#xFFFD;!"
  58. string(18) "262378464646443b21"
  59. Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
  60. string(2) "Ž®"
  61. string(4) "8eae"
  62. string(2) "Ž®"
  63. string(4) "8eae"
  64. Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
  65. string(8) "&#xFFFD;"
  66. string(16) "262378464646443b"
  67. string(8) "&#xFFFD;"
  68. string(16) "262378464646443b"
  69. Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
  70. string(9) "&#xFFFD;!"
  71. string(18) "262378464646443b21"
  72. string(9) "&#xFFFD;!"
  73. string(18) "262378464646443b21"
  74. Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
  75. string(8) "&#xFFFD;"
  76. string(16) "262378464646443b"
  77. string(8) "&#xFFFD;"
  78. string(16) "262378464646443b"
  79. Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
  80. string(8) "&#xFFFD;"
  81. string(16) "262378464646443b"
  82. string(8) "&#xFFFD;"
  83. string(16) "262378464646443b"
  84. Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
  85. string(9) "&#xFFFD;!"
  86. string(18) "262378464646443b21"
  87. string(9) "&#xFFFD;!"
  88. string(18) "262378464646443b21"
  89. Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
  90. string(8) "&#xFFFD;"
  91. string(16) "262378464646443b"
  92. string(8) "&#xFFFD;"
  93. string(16) "262378464646443b"