Table.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. namespace dokuwiki\Utf8;
  3. /**
  4. * Provides static access to the UTF-8 conversion tables
  5. *
  6. * Lazy-Loads tables on first access
  7. */
  8. class Table
  9. {
  10. /**
  11. * Get the upper to lower case conversion table
  12. *
  13. * @return array
  14. */
  15. public static function upperCaseToLowerCase()
  16. {
  17. static $table = null;
  18. if ($table === null) $table = include __DIR__ . '/tables/case.php';
  19. return $table;
  20. }
  21. /**
  22. * Get the lower to upper case conversion table
  23. *
  24. * @return array
  25. */
  26. public static function lowerCaseToUpperCase()
  27. {
  28. static $table = null;
  29. if ($table === null) {
  30. $uclc = self::upperCaseToLowerCase();
  31. $table = array_flip($uclc);
  32. }
  33. return $table;
  34. }
  35. /**
  36. * Get the lower case accent table
  37. * @return array
  38. */
  39. public static function lowerAccents()
  40. {
  41. static $table = null;
  42. if ($table === null) {
  43. $table = include __DIR__ . '/tables/loweraccents.php';
  44. }
  45. return $table;
  46. }
  47. /**
  48. * Get the lower case accent table
  49. * @return array
  50. */
  51. public static function upperAccents()
  52. {
  53. static $table = null;
  54. if ($table === null) {
  55. $table = include __DIR__ . '/tables/upperaccents.php';
  56. }
  57. return $table;
  58. }
  59. /**
  60. * Get the romanization table
  61. * @return array
  62. */
  63. public static function romanization()
  64. {
  65. static $table = null;
  66. if ($table === null) {
  67. $table = include __DIR__ . '/tables/romanization.php';
  68. }
  69. return $table;
  70. }
  71. /**
  72. * Get the special chars as a concatenated string
  73. * @return string
  74. */
  75. public static function specialChars()
  76. {
  77. static $string = null;
  78. if ($string === null) {
  79. $table = include __DIR__ . '/tables/specials.php';
  80. // FIXME should we cache this to file system?
  81. $string = Unicode::toUtf8($table);
  82. }
  83. return $string;
  84. }
  85. }