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