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