casemapping.phpt 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. --TEST--
  2. Unicode case mapping
  3. --EXTENSIONS--
  4. mbstring
  5. --FILE--
  6. <?php
  7. function toCases($str) {
  8. echo "String: $str\n";
  9. echo "Lower: ", mb_convert_case($str, MB_CASE_LOWER), "\n";
  10. echo "Lower Simple: ", mb_convert_case($str, MB_CASE_LOWER_SIMPLE), "\n";
  11. echo "Upper: ", mb_convert_case($str, MB_CASE_UPPER), "\n";
  12. echo "Upper Simple: ", mb_convert_case($str, MB_CASE_UPPER_SIMPLE), "\n";
  13. echo "Title: ", mb_convert_case($str, MB_CASE_TITLE), "\n";
  14. echo "Title Simple: ", mb_convert_case($str, MB_CASE_TITLE_SIMPLE), "\n";
  15. echo "Fold: ", mb_convert_case($str, MB_CASE_FOLD), "\n";
  16. echo "Fold Simple: ", mb_convert_case($str, MB_CASE_FOLD_SIMPLE), "\n";
  17. echo "\n";
  18. }
  19. toCases("ß");
  20. toCases("ff");
  21. toCases("İ");
  22. // Make sure that case-conversion in Turkish still works correctly.
  23. // Using the language-agnostic Unicode case mappings would result in
  24. // characters that are illegal under ISO-8859-9.
  25. mb_internal_encoding('ISO-8859-9');
  26. // Capital I with dot (U+0130)
  27. $str = "\xdd";
  28. echo bin2hex(mb_convert_case($str, MB_CASE_LOWER)), "\n";
  29. echo bin2hex(mb_convert_case($str, MB_CASE_LOWER_SIMPLE)), "\n";
  30. echo bin2hex(mb_convert_case($str, MB_CASE_FOLD)), "\n";
  31. echo bin2hex(mb_convert_case($str, MB_CASE_FOLD_SIMPLE)), "\n";
  32. echo "\n";
  33. // Lower i without dot (U+0131)
  34. $str = "\xfd";
  35. echo bin2hex(mb_convert_case($str, MB_CASE_UPPER)), "\n";
  36. echo bin2hex(mb_convert_case($str, MB_CASE_UPPER_SIMPLE)), "\n";
  37. echo bin2hex(mb_convert_case($str, MB_CASE_FOLD)), "\n";
  38. echo bin2hex(mb_convert_case($str, MB_CASE_FOLD_SIMPLE)), "\n";
  39. echo "\n";
  40. // Capital I without dot (U+0049)
  41. $str = "\x49";
  42. echo bin2hex(mb_convert_case($str, MB_CASE_LOWER)), "\n";
  43. echo bin2hex(mb_convert_case($str, MB_CASE_LOWER_SIMPLE)), "\n";
  44. echo bin2hex(mb_convert_case($str, MB_CASE_FOLD)), "\n";
  45. echo bin2hex(mb_convert_case($str, MB_CASE_FOLD_SIMPLE)), "\n";
  46. echo "\n";
  47. // Lower i with dot (U+0069)
  48. $str = "\x69";
  49. echo bin2hex(mb_convert_case($str, MB_CASE_UPPER)), "\n";
  50. echo bin2hex(mb_convert_case($str, MB_CASE_UPPER_SIMPLE)), "\n";
  51. echo bin2hex(mb_convert_case($str, MB_CASE_FOLD)), "\n";
  52. echo bin2hex(mb_convert_case($str, MB_CASE_FOLD_SIMPLE)), "\n";
  53. ?>
  54. --EXPECT--
  55. String: ß
  56. Lower: ß
  57. Lower Simple: ß
  58. Upper: SS
  59. Upper Simple: ß
  60. Title: Ss
  61. Title Simple: ß
  62. Fold: ss
  63. Fold Simple: ß
  64. String: ff
  65. Lower: ff
  66. Lower Simple: ff
  67. Upper: FF
  68. Upper Simple: ff
  69. Title: Ff
  70. Title Simple: ff
  71. Fold: ff
  72. Fold Simple: ff
  73. String: İ
  74. Lower: i̇
  75. Lower Simple: i
  76. Upper: İ
  77. Upper Simple: İ
  78. Title: İ
  79. Title Simple: İ
  80. Fold: i̇
  81. Fold Simple: İ
  82. 69
  83. 69
  84. 69
  85. 69
  86. 49
  87. 49
  88. fd
  89. fd
  90. fd
  91. fd
  92. fd
  93. fd
  94. dd
  95. dd
  96. 69
  97. 69