Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

ezcharsetinfo.php
Go to the documentation of this file.
1 <?php
24 class eZCharsetInfo
25 {
31 static function &aliasTable()
32 {
33 $aliasTable =& $GLOBALS['eZCharsetInfoTable'];
34 if ( !is_array( $aliasTable ) )
35 {
36 $aliasTable = array( 'ascii' => 'us-ascii',
37 'latin1' => 'iso-8859-1',
38 'latin2' => 'iso-8859-2',
39 'latin3' => 'iso-8859-3',
40 'latin4' => 'iso-8859-4',
41 'latin5' => 'iso-8859-9',
42 'latin6' => 'iso-8859-10',
43 'latin7' => 'iso-8859-13',
44 'latin8' => 'iso-8859-14',
45 'latin9' => 'iso-8859-15',
46 'cyrillic' => 'iso-8859-5',
47 'arabic' => 'iso-8859-6',
48 'greek' => 'iso-8859-7',
49 'hebrew' => 'iso-8859-8',
50 'thai' => 'iso-8859-11',
51
52 'koi8-r' => 'koi8-r',
53 'koi-8-r' => 'koi8-r',
54 'koi8r' => 'koi8-r',
55
56 'koi8-u' => 'koi8-u',
57 'koi-8-u' => 'koi8-u',
58 'koi8u' => 'koi8-u',
59
60 'cp1250' => 'windows-1250',
61 'cp1251' => 'windows-1251',
62 'cp1252' => 'windows-1252',
63 'cp1253' => 'windows-1253',
64 'cp1254' => 'windows-1254',
65 'cp1255' => 'windows-1255',
66 'cp1256' => 'windows-1256',
67 'cp1257' => 'windows-1257',
68 'cp1258' => 'windows-1258',
69 'winlatin1' => 'windows-1252',
70 'winlatin2' => 'windows-1250',
71 'wincyrillic' => 'windows-1251',
72 'wingreek' => 'windows-1253',
73 'winturkish' => 'windows-1254',
74 'winhebrew' => 'windows-1255',
75 'winarabic' => 'windows-1256',
76 'winbaltic' => 'windows-1257',
77 'winvietnamese' => 'windows-1258',
78
79 'doslatinus' => 'cp437',
80 'dosgreek' => 'cp737',
81 'dosbaltrim' => 'cp775',
82 'doslatin1' => 'cp850',
83 'doslatin2' => 'cp852',
84 'doscyrillic' => 'cp855',
85 'dosturkish' => 'cp857',
86 'dosportuguese' => 'cp860',
87 'dosicelandic' => 'cp861',
88 'doshebrew' => 'cp862',
89 'doscanadaf' => 'cp863',
90 'dosarabic' => 'cp864',
91 'dosnordic' => 'cp865',
92 'dosgreek2' => 'cp869',
93 'doscyrillicrussian' => 'cp866',
94 'dosthai' => 'cp874',
95
96 'macroman' => 'macintosh',
97 'nextstep' => 'next',
98
99 'utf8' => 'utf-8',
100 'utf7' => 'utf-7',
101
102 'utf16' => 'utf-16',
103 'utf16be' => 'utf-16be',
104 'utf16le' => 'utf-16le',
105
106 'utf32' => 'utf-32',
107 'utf32be' => 'utf-32be',
108 'utf32le' => 'utf-32le',
109
110 'ucs4' => 'ucs-4',
111 'ucs4be' => 'ucs-4be',
112 'ucs4le' => 'ucs-4le',
113
114 'ucs2' => 'ucs-2',
115 'ucs2be' => 'ucs-2be',
116 'ucs2le' => 'ucs-2le',
117
118 'shift-jis' => 'cp932',
119 'gbk' => 'gbk',
120 'euc-cn' => 'euc-cn',
121 'unifiedhangul' => 'cp849',
122 'uhc' => 'cp849',
123 'big5' => 'cp850'
124 );
125 for ( $i = 1; $i <= 15; ++$i )
126 {
127 $aliasTable["iso8859-$i"] = "iso-8859-$i";
128 $aliasTable["iso8859$i"] = "iso-8859-$i";
129 }
130 $aliasTable['unicode'] = 'unicode';
131 }
132 return $aliasTable;
133 }
134
142 static function &encodingTable()
143 {
144 $encodingTable =& $GLOBALS['eZCharsetInfoEncodingTable'];
145 if ( !is_array( $encodingTable ) )
146 {
147 $encodingTable = array( 'doublebyte' => array( 'cp932',
148 'GBK',
149 'euc-cn',
150 'cp849',
151 'cp850' ),
152 'unicode' => array( 'unicode' ),
153 'utf-8' => array( 'utf-8', 'utf8mb4' ) );
154 }
155 return $encodingTable;
156 }
157
165 static function &reverseEncodingTable()
166 {
167 $reverseEncodingTable =& $GLOBALS['eZCharsetInfoReverseEncodingTable'];
168 if ( !is_array( $reverseEncodingTable ) )
169 {
170 $encodingTable =& eZCharsetInfo::encodingTable();
171 $reverseEncodingTable = array();
172 foreach( $encodingTable as $encodingScheme => $charsetMatches )
173 {
174 foreach( $charsetMatches as $charsetMatch )
175 $reverseEncodingTable[$charsetMatch] = $encodingScheme;
176 }
177 }
178 return $reverseEncodingTable;
179 }
180
186 static function realCharsetCode( $charsetCode )
187 {
188 $aliasTable =& eZCharsetInfo::aliasTable();
189 $charsetCode = strtolower( $charsetCode );
190 if ( isset( $aliasTable[$charsetCode] ) )
191 return $aliasTable[$charsetCode];
192 // Check alias without any dashes
193 $charsetCodeNoDash = str_replace( '-', '', $charsetCode );
194 if ( isset( $aliasTable[$charsetCodeNoDash] ) )
195 return $aliasTable[$charsetCodeNoDash];
196 return $charsetCode;
197 }
198
206 static function characterEncodingScheme( $charsetCode, $isRealCharset = false )
207 {
208 if ( !$isRealCharset )
209 $charsetCode = eZCharsetInfo::realCharsetCode( $charsetCode );
210 $reverseEncodingTable =& eZCharsetInfo::reverseEncodingTable();
211 if ( isset( $reverseEncodingTable[$charsetCode] ) )
212 return $reverseEncodingTable[$charsetCode];
213 return 'singlebyte';
214 }
215 }
216
217 ?>
eZCharsetInfo
Allows for quering information about charsets.
Definition: ezcharsetinfo.php:25
eZCharsetInfo\aliasTable
static & aliasTable()
Definition: ezcharsetinfo.php:31
eZCharsetInfo\realCharsetCode
static realCharsetCode( $charsetCode)
Definition: ezcharsetinfo.php:186
eZCharsetInfo\characterEncodingScheme
static characterEncodingScheme( $charsetCode, $isRealCharset=false)
Definition: ezcharsetinfo.php:206
eZCharsetInfo\encodingTable
static & encodingTable()
Definition: ezcharsetinfo.php:142
eZCharsetInfo\reverseEncodingTable
static & reverseEncodingTable()
Definition: ezcharsetinfo.php:165
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.