59177427 |
1 | <?php |
1fd97780 |
2 | |
35586184 |
3 | /** |
2ba706ef |
4 | * functions/i18n.php |
35586184 |
5 | * |
2ba706ef |
6 | * Copyright (c) 1999-2004 The SquirrelMail Project Team |
35586184 |
7 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
8 | * |
9 | * This file contains variuos functions that are needed to do |
10 | * internationalization of SquirrelMail. |
11 | * |
12 | * Internally the output character set is used. Other characters are |
13 | * encoded using Unicode entities according to HTML 4.0. |
14 | * |
a8a1c36d |
15 | * @version $Id$ |
d6c32258 |
16 | * @package squirrelmail |
a8a1c36d |
17 | * @subpackage i18n |
35586184 |
18 | */ |
19 | |
d6c32258 |
20 | /** Everything uses global.php... */ |
961ca3d8 |
21 | require_once(SM_PATH . 'functions/global.php'); |
22 | |
d6c32258 |
23 | /** |
51468260 |
24 | * Converts string from given charset to charset, that can be displayed by user translation. |
25 | * |
26 | * Function by default returns html encoded strings, if translation uses different encoding. |
27 | * If Japanese translation is used - function returns string converted to euc-jp |
28 | * If iconv or recode functions are enabled and translation uses utf-8 - function returns utf-8 encoded string. |
29 | * If $charset is not supported - function returns unconverted string. |
d6c32258 |
30 | * |
51468260 |
31 | * sanitizing of html tags is also done by this function. |
32 | * |
d6c32258 |
33 | * @param string $charset |
34 | * @param string $string Text to be decoded |
51468260 |
35 | * @return string decoded string |
d6c32258 |
36 | */ |
a2a7852b |
37 | function charset_decode ($charset, $string) { |
3ec81e63 |
38 | global $languages, $squirrelmail_language, $default_charset; |
edf2c0ba |
39 | global $use_php_recode, $use_php_iconv, $agresive_decoding; |
a2a7852b |
40 | |
3714db45 |
41 | if (isset($languages[$squirrelmail_language]['XTRA_CODE']) && |
42 | function_exists($languages[$squirrelmail_language]['XTRA_CODE'])) { |
6fbd125b |
43 | $string = $languages[$squirrelmail_language]['XTRA_CODE']('decode', $string); |
44 | } |
b05c8961 |
45 | |
3ec81e63 |
46 | $charset = strtolower($charset); |
47 | |
48 | set_my_charset(); |
49 | |
50 | // Variables that allow to use functions without function_exist() calls |
edf2c0ba |
51 | if (! isset($use_php_recode) || $use_php_recode=="" ) { |
52 | $use_php_recode=false; } |
53 | if (! isset($use_php_iconv) || $use_php_iconv=="" ) { |
54 | $use_php_iconv=false; } |
3ec81e63 |
55 | |
56 | // Don't do conversion if charset is the same. |
57 | if ( $charset == strtolower($default_charset) ) |
58 | return htmlspecialchars($string); |
59 | |
60 | // catch iso-8859-8-i thing |
61 | if ( $charset == "iso-8859-8-i" ) |
62 | $charset = "iso-8859-8"; |
63 | |
64 | /* |
65 | * Recode converts html special characters automatically if you use |
66 | * 'charset..html' decoding. There is no documented way to put -d option |
67 | * into php recode function call. |
68 | */ |
69 | if ( $use_php_recode ) { |
70 | if ( $default_charset == "utf-8" ) { |
71 | // other charsets can be converted to utf-8 without loss. |
72 | // and output string is smaller |
73 | $string = recode_string($charset . "..utf-8",$string); |
74 | return htmlspecialchars($string); |
75 | } else { |
76 | $string = recode_string($charset . "..html",$string); |
77 | // recode does not convert single quote, htmlspecialchars does. |
78 | $string = str_replace("'", ''', $string); |
79 | return $string; |
80 | } |
81 | } |
82 | |
83 | // iconv functions does not have html target and can be used only with utf-8 |
84 | if ( $use_php_iconv && $default_charset=='utf-8') { |
85 | $string = iconv($charset,$default_charset,$string); |
86 | return htmlspecialchars($string); |
87 | } |
88 | |
89 | // If we don't use recode and iconv, we'll do it old way. |
90 | |
a2a7852b |
91 | /* All HTML special characters are 7 bit and can be replaced first */ |
cef054e4 |
92 | |
098ea084 |
93 | $string = htmlspecialchars ($string); |
a2a7852b |
94 | |
5dd23dac |
95 | /* controls cpu and memory intensive decoding cycles */ |
edf2c0ba |
96 | if (! isset($agresive_decoding) || $agresive_decoding=="" ) { |
97 | $agresive_decoding=false; } |
5dd23dac |
98 | |
b142de74 |
99 | $decode=fixcharset($charset); |
100 | $decodefile=SM_PATH . 'functions/decode/' . $decode . '.php'; |
101 | if (file_exists($decodefile)) { |
102 | include_once($decodefile); |
103 | $ret = call_user_func('charset_decode_'.$decode, $string); |
a2a7852b |
104 | } else { |
b142de74 |
105 | $ret = $string; |
a2a7852b |
106 | } |
107 | return( $ret ); |
108 | } |
b142de74 |
109 | |
110 | /** |
111 | * Makes charset name suitable for decoding cycles |
112 | * |
113 | * @param string $charset Name of charset |
114 | * @return string $charset Adjusted name of charset |
115 | */ |
116 | function fixcharset($charset) { |
117 | // minus removed from function names |
118 | $charset=str_replace('-','_',$charset); |
119 | |
120 | // windows-125x and cp125x charsets |
121 | $charset=str_replace('windows_','cp',$charset); |
a2a7852b |
122 | |
b142de74 |
123 | // ibm > cp |
124 | $charset=str_replace('ibm','cp',$charset); |
125 | |
126 | // iso-8859-8-i -> iso-8859-8 |
127 | // use same cycle until I'll find differences |
128 | $charset=str_replace('iso_8859_8_i','iso_8859_8',$charset); |
129 | |
130 | return $charset; |
131 | } |
a2a7852b |
132 | |
51468260 |
133 | /** |
a2a7852b |
134 | * Set up the language to be output |
135 | * if $do_search is true, then scan the browser information |
136 | * for a possible language that we know |
51468260 |
137 | * |
138 | * Function sets system locale environment (LC_ALL, LANG, LANGUAGE), |
139 | * gettext translation bindings and html header information. |
140 | * |
5679405c |
141 | * Function returns error codes, if there is some fatal error. |
51468260 |
142 | * 0 = no error, |
143 | * 1 = mbstring support is not present, |
144 | * 2 = mbstring support is not present, user's translation reverted to en_US. |
145 | * |
146 | * @param string $sm_language translation used by user's interface |
147 | * @param bool $do_search use browser's preferred language detection functions. Defaults to false. |
148 | * @param bool $default set $sm_language to $squirrelmail_default_language if language detection fails or language is not set. Defaults to false. |
149 | * @return int function execution error codes. |
a2a7852b |
150 | */ |
67a8c90a |
151 | function set_up_language($sm_language, $do_search = false, $default = false) { |
a2a7852b |
152 | |
153 | static $SetupAlready = 0; |
9eb0fbd4 |
154 | global $use_gettext, $languages, |
a2a7852b |
155 | $squirrelmail_language, $squirrelmail_default_language, |
51468260 |
156 | $sm_notAlias, $username, $data_dir; |
a2a7852b |
157 | |
158 | if ($SetupAlready) { |
159 | return; |
160 | } |
a65846a7 |
161 | |
5c920668 |
162 | $SetupAlready = TRUE; |
961ca3d8 |
163 | sqgetGlobalVar('HTTP_ACCEPT_LANGUAGE', $accept_lang, SQ_SERVER); |
a2a7852b |
164 | |
961ca3d8 |
165 | if ($do_search && ! $sm_language && isset($accept_lang)) { |
166 | $sm_language = substr($accept_lang, 0, 2); |
a2a7852b |
167 | } |
66d7950f |
168 | |
67a8c90a |
169 | if ((!$sm_language||$default) && isset($squirrelmail_default_language)) { |
a2a7852b |
170 | $squirrelmail_language = $squirrelmail_default_language; |
66d7950f |
171 | $sm_language = $squirrelmail_default_language; |
a2a7852b |
172 | } |
173 | $sm_notAlias = $sm_language; |
3ec81e63 |
174 | |
175 | // Catching removed translation |
176 | // System reverts to English translation if user prefs contain translation |
2ba706ef |
177 | // that is not available in $languages array |
3ec81e63 |
178 | if (!isset($languages[$sm_notAlias])) { |
179 | $sm_notAlias="en_US"; |
180 | } |
181 | |
a2a7852b |
182 | while (isset($languages[$sm_notAlias]['ALIAS'])) { |
183 | $sm_notAlias = $languages[$sm_notAlias]['ALIAS']; |
184 | } |
185 | |
88cb1b4d |
186 | if ( isset($sm_language) && |
5c920668 |
187 | $use_gettext && |
188 | $sm_language != '' && |
189 | isset($languages[$sm_notAlias]['CHARSET']) ) { |
a65846a7 |
190 | bindtextdomain( 'squirrelmail', SM_PATH . 'locale/' ); |
88cb1b4d |
191 | textdomain( 'squirrelmail' ); |
7928848f |
192 | if (function_exists('bind_textdomain_codeset')) { |
a5970d71 |
193 | if ($sm_notAlias == 'ja_JP') { |
194 | bind_textdomain_codeset ("squirrelmail", 'EUC-JP'); |
195 | } else { |
196 | bind_textdomain_codeset ("squirrelmail", $languages[$sm_notAlias]['CHARSET'] ); |
197 | } |
7928848f |
198 | } |
f2374580 |
199 | if (isset($languages[$sm_notAlias]['LOCALE'])){ |
200 | $longlocale=$languages[$sm_notAlias]['LOCALE']; |
201 | } else { |
202 | $longlocale=$sm_notAlias; |
203 | } |
88cb1b4d |
204 | if ( !ini_get('safe_mode') && |
f2374580 |
205 | getenv( 'LC_ALL' ) != $longlocale ) { |
206 | putenv( "LC_ALL=$longlocale" ); |
207 | putenv( "LANG=$longlocale" ); |
208 | putenv( "LANGUAGE=$longlocale" ); |
a2a7852b |
209 | } |
f2374580 |
210 | setlocale(LC_ALL, $longlocale); |
d9d28bdc |
211 | |
212 | // Set text direction/alignment variables |
213 | if (isset($languages[$sm_notAlias]['DIR']) && |
214 | $languages[$sm_notAlias]['DIR'] == 'rtl') { |
a8a1c36d |
215 | /** |
216 | * Text direction |
217 | * @global string $text_direction |
218 | */ |
d9d28bdc |
219 | $text_direction='rtl'; |
a8a1c36d |
220 | /** |
221 | * Left alignment |
222 | * @global string $left_align |
223 | */ |
d9d28bdc |
224 | $left_align='right'; |
a8a1c36d |
225 | /** |
226 | * Right alignment |
227 | * @global string $right_align |
228 | */ |
d9d28bdc |
229 | $right_align='left'; |
230 | } else { |
231 | $text_direction='ltr'; |
232 | $left_align='left'; |
233 | $right_align='right'; |
234 | } |
235 | |
f2374580 |
236 | $squirrelmail_language = $sm_notAlias; |
a5970d71 |
237 | if ($squirrelmail_language == 'ja_JP') { |
b05c8961 |
238 | header ('Content-Type: text/html; charset=EUC-JP'); |
239 | if (!function_exists('mb_internal_encoding')) { |
51468260 |
240 | // Error messages can't be displayed here |
241 | $error = 1; |
242 | // Revert to English if possible. |
243 | if (function_exists('setPref') && $username!='' && $data_dir!="") { |
244 | setPref($data_dir, $username, 'language', "en_US"); |
245 | $error = 2; |
246 | } |
a5970d71 |
247 | // stop further execution in order not to get php errors on mb_internal_encoding(). |
51468260 |
248 | return $error; |
e842b215 |
249 | } |
250 | if (function_exists('mb_language')) { |
251 | mb_language('Japanese'); |
b05c8961 |
252 | } |
253 | mb_internal_encoding('EUC-JP'); |
254 | mb_http_output('pass'); |
255 | } else { |
5c920668 |
256 | header( 'Content-Type: text/html; charset=' . $languages[$sm_notAlias]['CHARSET'] ); |
a2a7852b |
257 | } |
258 | } |
51468260 |
259 | return 0; |
b05c8961 |
260 | } |
a2a7852b |
261 | |
51468260 |
262 | /** |
263 | * Sets default_charset variable according to the one that is used by user's translations. |
264 | * |
265 | * Function changes global $default_charset variable in order to be sure, that it |
266 | * contains charset used by user's translation. Sanity of $squirrelmail_default_language |
267 | * and $default_charset combination provided in SquirrelMail config is also tested. |
268 | * |
269 | * There can be a $default_charset setting in the |
270 | * config.php file, but the user may have a different language |
271 | * selected for a user interface. This function checks the |
272 | * language selected by the user and tags the outgoing messages |
273 | * with the appropriate charset corresponding to the language |
274 | * selection. This is "more right" (tm), than just stamping the |
275 | * message blindly with the system-wide $default_charset. |
276 | */ |
a2a7852b |
277 | function set_my_charset(){ |
94965562 |
278 | global $data_dir, $username, $default_charset, $languages, $squirrelmail_default_language; |
88cb1b4d |
279 | |
a2a7852b |
280 | $my_language = getPref($data_dir, $username, 'language'); |
5c920668 |
281 | if (!$my_language) { |
94965562 |
282 | $my_language = $squirrelmail_default_language ; |
5c920668 |
283 | } |
3ec81e63 |
284 | // Catch removed translation |
285 | if (!isset($languages[$my_language])) { |
286 | $my_language="en_US"; |
287 | } |
a2a7852b |
288 | while (isset($languages[$my_language]['ALIAS'])) { |
f7e8861e |
289 | $my_language = $languages[$my_language]['ALIAS']; |
a2a7852b |
290 | } |
5c920668 |
291 | $my_charset = $languages[$my_language]['CHARSET']; |
a2a7852b |
292 | if ($my_charset) { |
293 | $default_charset = $my_charset; |
294 | } |
295 | } |
296 | |
a2a7852b |
297 | /* ------------------------------ main --------------------------- */ |
298 | |
5c920668 |
299 | global $squirrelmail_language, $languages, $use_gettext; |
300 | |
a2a7852b |
301 | if (! isset($squirrelmail_language)) { |
302 | $squirrelmail_language = ''; |
303 | } |
304 | |
51468260 |
305 | /** |
306 | * Array specifies the available translations. |
307 | * |
308 | * Structure of array: |
309 | * $languages['language']['variable'] = 'value' |
310 | * |
311 | * Possible 'variable' names: |
312 | * NAME - Translation name in English |
313 | * CHARSET - Encoding used by translation |
314 | * ALIAS - used when 'language' is only short name and 'value' should provide long language name |
315 | * ALTNAME - Native translation name. Any 8bit symbols must be html encoded. |
316 | * LOCALE - Full locale name (in xx_XX.charset format) |
317 | * DIR - Text direction. Used to define Right-to-Left languages. Possible values 'rtl' or 'ltr'. If undefined - defaults to 'ltr' |
318 | * XTRA_CODE - translation uses special functions. 'value' provides name of that extra function |
319 | * |
320 | * Each 'language' definition requires NAME+CHARSET or ALIAS variables. |
321 | * |
322 | * @name $languages |
a8a1c36d |
323 | * @global array $languages |
51468260 |
324 | */ |
a8fa8e33 |
325 | $languages['bg_BG']['NAME'] = 'Bulgarian'; |
326 | $languages['bg_BG']['ALTNAME'] = 'Български'; |
327 | $languages['bg_BG']['CHARSET'] = 'windows-1251'; |
c30be3cf |
328 | $languages['bg_BG']['LOCALE'] = 'bg_BG.CP1251'; |
a8fa8e33 |
329 | $languages['bg']['ALIAS'] = 'bg_BG'; |
330 | |
331 | $languages['ca_ES']['NAME'] = 'Catalan'; |
332 | $languages['ca_ES']['CHARSET'] = 'iso-8859-1'; |
a00d341d |
333 | $languages['ca_ES']['LOCALE'] = 'ca_ES.ISO8859-1'; |
a8fa8e33 |
334 | $languages['ca']['ALIAS'] = 'ca_ES'; |
335 | |
336 | $languages['cs_CZ']['NAME'] = 'Czech'; |
337 | $languages['cs_CZ']['ALTNAME'] = 'Čeština'; |
338 | $languages['cs_CZ']['CHARSET'] = 'iso-8859-2'; |
a00d341d |
339 | $languages['cs_CZ']['LOCALE'] = 'cs_CZ.ISO8859-2'; |
a8fa8e33 |
340 | $languages['cs']['ALIAS'] = 'cs_CZ'; |
341 | |
342 | $languages['cy_GB']['NAME'] = 'Welsh'; |
343 | $languages['cy_GB']['ALTNAME'] = 'Cymraeg'; |
344 | $languages['cy_GB']['CHARSET'] = 'iso-8859-1'; |
a00d341d |
345 | $languages['cy_GB']['LOCALE'] = 'cy_GB.ISO8859-1'; |
a8fa8e33 |
346 | $languages['cy']['ALIAS'] = 'cy_GB'; |
347 | |
348 | // Danish locale is da_DK. |
349 | $languages['da_DK']['NAME'] = 'Danish'; |
350 | $languages['da_DK']['ALTNAME'] = 'Dansk'; |
351 | $languages['da_DK']['CHARSET'] = 'iso-8859-1'; |
a00d341d |
352 | $languages['da_DK']['LOCALE'] = 'da_DK.ISO8859-1'; |
a8fa8e33 |
353 | $languages['da']['ALIAS'] = 'da_DK'; |
354 | |
355 | $languages['de_DE']['NAME'] = 'German'; |
356 | $languages['de_DE']['ALTNAME'] = 'Deutsch'; |
357 | $languages['de_DE']['CHARSET'] = 'iso-8859-1'; |
a00d341d |
358 | $languages['de_DE']['LOCALE'] = 'de_DE.ISO8859-1'; |
a8fa8e33 |
359 | $languages['de']['ALIAS'] = 'de_DE'; |
360 | |
361 | $languages['el_GR']['NAME'] = 'Greek'; |
362 | $languages['el_GR']['ALTNAME'] = 'Ελληνικά'; |
363 | $languages['el_GR']['CHARSET'] = 'iso-8859-7'; |
a00d341d |
364 | $languages['el_GR']['LOCALE'] = 'el_GR.ISO8859-7'; |
a8fa8e33 |
365 | $languages['el']['ALIAS'] = 'el_GR'; |
a2a7852b |
366 | |
3bb3d83b |
367 | $languages['en_GB']['NAME'] = 'British'; |
368 | $languages['en_GB']['CHARSET'] = 'iso-8859-15'; |
a00d341d |
369 | $languages['en_GB']['LOCALE'] = 'en_GB.ISO8859-15'; |
3bb3d83b |
370 | |
5c920668 |
371 | $languages['en_US']['NAME'] = 'English'; |
372 | $languages['en_US']['CHARSET'] = 'iso-8859-1'; |
a00d341d |
373 | $languages['en_US']['LOCALE'] = 'en_US.ISO8859-1'; |
5c920668 |
374 | $languages['en']['ALIAS'] = 'en_US'; |
a2a7852b |
375 | |
a8fa8e33 |
376 | $languages['es_ES']['NAME'] = 'Spanish'; |
377 | $languages['es_ES']['ALTNAME'] = 'Español'; |
378 | $languages['es_ES']['CHARSET'] = 'iso-8859-1'; |
a00d341d |
379 | $languages['es_ES']['LOCALE'] = 'es_ES.ISO8859-1'; |
a8fa8e33 |
380 | $languages['es']['ALIAS'] = 'es_ES'; |
381 | |
382 | $languages['et_EE']['NAME'] = 'Estonian'; |
383 | $languages['et_EE']['CHARSET'] = 'iso-8859-15'; |
a00d341d |
384 | $languages['et_EE']['LOCALE'] = 'et_EE.ISO8859-15'; |
a8fa8e33 |
385 | $languages['et']['ALIAS'] = 'et_EE'; |
386 | |
387 | $languages['fo_FO']['NAME'] = 'Faroese'; |
388 | $languages['fo_FO']['CHARSET'] = 'iso-8859-1'; |
a00d341d |
389 | $languages['fo_FO']['LOCALE'] = 'fo_FO.ISO8859-1'; |
a8fa8e33 |
390 | $languages['fo']['ALIAS'] = 'fo_FO'; |
391 | |
392 | $languages['fi_FI']['NAME'] = 'Finnish'; |
393 | $languages['fi_FI']['ALTNAME'] = 'Suomi'; |
394 | $languages['fi_FI']['CHARSET'] = 'iso-8859-1'; |
a00d341d |
395 | $languages['fi_FI']['LOCALE'] = 'fi_FI.ISO8859-1'; |
a8fa8e33 |
396 | $languages['fi']['ALIAS'] = 'fi_FI'; |
397 | |
398 | $languages['fr_FR']['NAME'] = 'French'; |
399 | $languages['fr_FR']['ALTNAME'] = 'Français'; |
400 | $languages['fr_FR']['CHARSET'] = 'iso-8859-1'; |
a00d341d |
401 | $languages['fr_FR']['LOCALE'] = 'fr_FR.ISO8859-1'; |
a8fa8e33 |
402 | $languages['fr']['ALIAS'] = 'fr_FR'; |
403 | |
404 | $languages['hr_HR']['NAME'] = 'Croatian'; |
405 | $languages['hr_HR']['CHARSET'] = 'iso-8859-2'; |
a00d341d |
406 | $languages['hr_HR']['LOCALE'] = 'hr_HR.ISO8859-2'; |
a8fa8e33 |
407 | $languages['hr']['ALIAS'] = 'hr_HR'; |
408 | |
409 | $languages['hu_HU']['NAME'] = 'Hungarian'; |
410 | $languages['hu_HU']['ALTNAME'] = 'Magyar'; |
411 | $languages['hu_HU']['CHARSET'] = 'iso-8859-2'; |
a00d341d |
412 | $languages['hu_HU']['LOCALE'] = 'hu_HU.ISO8859-2'; |
a8fa8e33 |
413 | $languages['hu']['ALIAS'] = 'hu_HU'; |
414 | |
415 | $languages['id_ID']['NAME'] = 'Indonesian'; |
416 | $languages['id_ID']['ALTNAME'] = 'Bahasa Indonesia'; |
417 | $languages['id_ID']['CHARSET'] = 'iso-8859-1'; |
a00d341d |
418 | $languages['id_ID']['LOCALE'] = 'id_ID.ISO8859-1'; |
a8fa8e33 |
419 | $languages['id']['ALIAS'] = 'id_ID'; |
420 | |
421 | $languages['is_IS']['NAME'] = 'Icelandic'; |
422 | $languages['is_IS']['ALTNAME'] = 'Íslenska'; |
423 | $languages['is_IS']['CHARSET'] = 'iso-8859-1'; |
a00d341d |
424 | $languages['is_IS']['LOCALE'] = 'is_IS.ISO8859-1'; |
a8fa8e33 |
425 | $languages['is']['ALIAS'] = 'is_IS'; |
426 | |
427 | $languages['it_IT']['NAME'] = 'Italian'; |
428 | $languages['it_IT']['CHARSET'] = 'iso-8859-1'; |
a00d341d |
429 | $languages['it_IT']['LOCALE'] = 'it_IT.ISO8859-1'; |
a8fa8e33 |
430 | $languages['it']['ALIAS'] = 'it_IT'; |
431 | |
432 | $languages['ja_JP']['NAME'] = 'Japanese'; |
433 | $languages['ja_JP']['ALTNAME'] = '日本語'; |
434 | $languages['ja_JP']['CHARSET'] = 'iso-2022-jp'; |
51468260 |
435 | $languages['ja_JP']['LOCALE'] = 'ja_JP.EUC-JP'; |
a8fa8e33 |
436 | $languages['ja_JP']['XTRA_CODE'] = 'japanese_charset_xtra'; |
437 | $languages['ja']['ALIAS'] = 'ja_JP'; |
438 | |
439 | $languages['ko_KR']['NAME'] = 'Korean'; |
440 | $languages['ko_KR']['CHARSET'] = 'euc-KR'; |
c30be3cf |
441 | $languages['ko_KR']['LOCALE'] = 'ko_KR.EUC-KR'; |
a8fa8e33 |
442 | $languages['ko_KR']['XTRA_CODE'] = 'korean_charset_xtra'; |
443 | $languages['ko']['ALIAS'] = 'ko_KR'; |
444 | |
445 | $languages['lt_LT']['NAME'] = 'Lithuanian'; |
446 | $languages['lt_LT']['ALTNAME'] = 'Lietuvių'; |
447 | $languages['lt_LT']['CHARSET'] = 'utf-8'; |
448 | $languages['lt_LT']['LOCALE'] = 'lt_LT.UTF-8'; |
449 | $languages['lt']['ALIAS'] = 'lt_LT'; |
450 | |
451 | $languages['nl_NL']['NAME'] = 'Dutch'; |
452 | $languages['nl_NL']['ALTNAME'] = 'Nederlands'; |
453 | $languages['nl_NL']['CHARSET'] = 'iso-8859-1'; |
a00d341d |
454 | $languages['nl_NL']['LOCALE'] = 'nl_NL.ISO8859-1'; |
a8fa8e33 |
455 | $languages['nl']['ALIAS'] = 'nl_NL'; |
456 | |
457 | $languages['ms_MY']['NAME'] = 'Malay'; |
458 | $languages['ms_MY']['ALTNAME'] = 'Bahasa Melayu'; |
459 | $languages['ms_MY']['CHARSET'] = 'iso-8859-1'; |
a00d341d |
460 | $languages['ms_MY']['LOCALE'] = 'ms_MY.ISO8859-1'; |
a8fa8e33 |
461 | $languages['my']['ALIAS'] = 'ms_MY'; |
462 | |
850db3c8 |
463 | $languages['nb_NO']['NAME'] = 'Norwegian (Bokmål)'; |
464 | $languages['nb_NO']['ALTNAME'] = 'Norsk (Bokmål)'; |
465 | $languages['nb_NO']['CHARSET'] = 'iso-8859-1'; |
a00d341d |
466 | $languages['nb_NO']['LOCALE'] = 'nb_NO.ISO8859-1'; |
850db3c8 |
467 | $languages['nb']['ALIAS'] = 'nb_NO'; |
a8fa8e33 |
468 | |
469 | $languages['nn_NO']['NAME'] = 'Norwegian (Nynorsk)'; |
470 | $languages['nn_NO']['ALTNAME'] = 'Norsk (Nynorsk)'; |
471 | $languages['nn_NO']['CHARSET'] = 'iso-8859-1'; |
a00d341d |
472 | $languages['nn_NO']['LOCALE'] = 'nn_NO.ISO8859-1'; |
a8fa8e33 |
473 | |
474 | $languages['pl_PL']['NAME'] = 'Polish'; |
475 | $languages['pl_PL']['ALTNAME'] = 'Polski'; |
476 | $languages['pl_PL']['CHARSET'] = 'iso-8859-2'; |
a00d341d |
477 | $languages['pl_PL']['LOCALE'] = 'pl_PL.ISO8859-2'; |
a8fa8e33 |
478 | $languages['pl']['ALIAS'] = 'pl_PL'; |
479 | |
480 | $languages['pt_PT']['NAME'] = 'Portuguese (Portugal)'; |
481 | $languages['pt_PT']['CHARSET'] = 'iso-8859-1'; |
a00d341d |
482 | $languages['pt_PT']['LOCALE'] = 'pt_PT.ISO8859-1'; |
a8fa8e33 |
483 | $languages['pt']['ALIAS'] = 'pt_PT'; |
484 | |
485 | $languages['pt_BR']['NAME'] = 'Portuguese (Brazil)'; |
486 | $languages['pt_BR']['ALTNAME'] = 'Português do Brasil'; |
487 | $languages['pt_BR']['CHARSET'] = 'iso-8859-1'; |
a00d341d |
488 | $languages['pt_BR']['LOCALE'] = 'pt_BR.ISO8859-1'; |
a8fa8e33 |
489 | |
490 | $languages['ro_RO']['NAME'] = 'Romanian'; |
491 | $languages['ro_RO']['ALTNAME'] = 'Română'; |
492 | $languages['ro_RO']['CHARSET'] = 'iso-8859-2'; |
a00d341d |
493 | $languages['ro_RO']['LOCALE'] = 'ro_RO.ISO8859-2'; |
a8fa8e33 |
494 | $languages['ro']['ALIAS'] = 'ro_RO'; |
495 | |
496 | $languages['ru_RU']['NAME'] = 'Russian'; |
497 | $languages['ru_RU']['ALTNAME'] = 'Русский'; |
498 | $languages['ru_RU']['CHARSET'] = 'utf-8'; |
c30be3cf |
499 | $languages['ru_RU']['LOCALE'] = 'ru_RU.UTF-8'; |
a8fa8e33 |
500 | $languages['ru']['ALIAS'] = 'ru_RU'; |
501 | |
c30be3cf |
502 | $languages['sk_SK']['NAME'] = 'Slovak'; |
503 | $languages['sk_SK']['CHARSET'] = 'iso-8859-2'; |
a00d341d |
504 | $languages['sk_SK']['LOCALE'] = 'sk_SK.ISO8859-2'; |
c30be3cf |
505 | $languages['sk']['ALIAS'] = 'sk_SK'; |
a8fa8e33 |
506 | |
507 | $languages['sl_SI']['NAME'] = 'Slovenian'; |
508 | $languages['sl_SI']['ALTNAME'] = 'Slovenščina'; |
509 | $languages['sl_SI']['CHARSET'] = 'iso-8859-2'; |
a00d341d |
510 | $languages['sl_SI']['LOCALE'] = 'sl_SI.ISO8859-2'; |
a8fa8e33 |
511 | $languages['sl']['ALIAS'] = 'sl_SI'; |
512 | |
513 | $languages['sr_YU']['NAME'] = 'Serbian'; |
514 | $languages['sr_YU']['ALTNAME'] = 'Srpski'; |
515 | $languages['sr_YU']['CHARSET'] = 'iso-8859-2'; |
a00d341d |
516 | $languages['sr_YU']['LOCALE'] = 'sr_YU.ISO8859-2'; |
a8fa8e33 |
517 | $languages['sr']['ALIAS'] = 'sr_YU'; |
518 | |
519 | $languages['sv_SE']['NAME'] = 'Swedish'; |
520 | $languages['sv_SE']['ALTNAME'] = 'Svenska'; |
521 | $languages['sv_SE']['CHARSET'] = 'iso-8859-1'; |
a00d341d |
522 | $languages['sv_SE']['LOCALE'] = 'sv_SE.ISO8859-1'; |
a8fa8e33 |
523 | $languages['sv']['ALIAS'] = 'sv_SE'; |
524 | |
525 | $languages['th_TH']['NAME'] = 'Thai'; |
526 | $languages['th_TH']['CHARSET'] = 'tis-620'; |
c30be3cf |
527 | $languages['th_TH']['LOCALE'] = 'th_TH.TIS-620'; |
a8fa8e33 |
528 | $languages['th']['ALIAS'] = 'th_TH'; |
529 | |
551a09c7 |
530 | $languages['tl_PH']['NAME'] = 'Tagalog'; |
531 | $languages['tl_PH']['CHARSET'] = 'iso-8859-1'; |
a00d341d |
532 | $languages['tl_PH']['LOCALE'] = 'tl_PH.ISO8859-1'; |
551a09c7 |
533 | $languages['tl']['ALIAS'] = 'tl_PH'; |
534 | |
a8fa8e33 |
535 | $languages['tr_TR']['NAME'] = 'Turkish'; |
536 | $languages['tr_TR']['CHARSET'] = 'iso-8859-9'; |
a00d341d |
537 | $languages['tr_TR']['LOCALE'] = 'tr_TR.ISO8859-9'; |
a8fa8e33 |
538 | $languages['tr']['ALIAS'] = 'tr_TR'; |
539 | |
540 | $languages['zh_TW']['NAME'] = 'Chinese Trad'; |
541 | $languages['zh_TW']['CHARSET'] = 'big5'; |
c30be3cf |
542 | $languages['zh_TW']['LOCALE'] = 'zh_TW.BIG5'; |
a8fa8e33 |
543 | $languages['tw']['ALIAS'] = 'zh_TW'; |
544 | |
545 | $languages['zh_CN']['NAME'] = 'Chinese Simp'; |
546 | $languages['zh_CN']['CHARSET'] = 'gb2312'; |
c30be3cf |
547 | $languages['zh_CN']['LOCALE'] = 'zh_CN.GB2312'; |
a8fa8e33 |
548 | $languages['cn']['ALIAS'] = 'zh_CN'; |
060c9483 |
549 | |
a8fa8e33 |
550 | $languages['uk_UA']['NAME'] = 'Ukrainian'; |
551 | $languages['uk_UA']['CHARSET'] = 'koi8-u'; |
c30be3cf |
552 | $languages['uk_UA']['LOCALE'] = 'uk_UA.KOI8-U'; |
a8fa8e33 |
553 | $languages['uk']['ALIAS'] = 'uk_UA'; |
c30be3cf |
554 | |
555 | $languages['ru_UA']['NAME'] = 'Russian (Ukrainian)'; |
556 | $languages['ru_UA']['CHARSET'] = 'koi8-r'; |
557 | $languages['ru_UA']['LOCALE'] = 'ru_UA.KOI8-R'; |
558 | |
87c6b544 |
559 | /* |
850db3c8 |
560 | $languages['vi_VN']['NAME'] = 'Vietnamese'; |
561 | $languages['vi_VN']['CHARSET'] = 'utf-8'; |
562 | $languages['vi']['ALIAS'] = 'vi_VN'; |
87c6b544 |
563 | */ |
a8fa8e33 |
564 | |
d3b57948 |
565 | // Right to left languages |
a8fa8e33 |
566 | $languages['ar']['NAME'] = 'Arabic'; |
567 | $languages['ar']['CHARSET'] = 'windows-1256'; |
568 | $languages['ar']['DIR'] = 'rtl'; |
569 | |
4417eead |
570 | $languages['fa_IR']['NAME'] = 'Farsi'; |
571 | $languages['fa_IR']['CHARSET'] = 'utf-8'; |
572 | $languages['fa_IR']['DIR'] = 'rtl'; |
573 | $languages['fa_IR']['LOCALE'] = 'fa_IR.UTF-8'; |
574 | $languages['fa']['ALIAS'] = 'fa_IR'; |
575 | |
a8fa8e33 |
576 | $languages['he_IL']['NAME'] = 'Hebrew'; |
577 | $languages['he_IL']['CHARSET'] = 'windows-1255'; |
c30be3cf |
578 | $languages['he_IL']['LOCALE'] = 'he_IL.CP1255'; |
a8fa8e33 |
579 | $languages['he_IL']['DIR'] = 'rtl'; |
580 | $languages['he']['ALIAS'] = 'he_IL'; |
d3b57948 |
581 | |
5c920668 |
582 | /* Detect whether gettext is installed. */ |
a2a7852b |
583 | $gettext_flags = 0; |
584 | if (function_exists('_')) { |
585 | $gettext_flags += 1; |
586 | } |
587 | if (function_exists('bindtextdomain')) { |
588 | $gettext_flags += 2; |
589 | } |
590 | if (function_exists('textdomain')) { |
591 | $gettext_flags += 4; |
592 | } |
593 | |
5c920668 |
594 | /* If gettext is fully loaded, cool */ |
a2a7852b |
595 | if ($gettext_flags == 7) { |
596 | $use_gettext = true; |
597 | } |
5c920668 |
598 | /* If we can fake gettext, try that */ |
a2a7852b |
599 | elseif ($gettext_flags == 0) { |
600 | $use_gettext = true; |
e7ab8c9d |
601 | include_once(SM_PATH . 'functions/gettext.php'); |
a2a7852b |
602 | } else { |
5c920668 |
603 | /* Uh-ho. A weird install */ |
a2a7852b |
604 | if (! $gettext_flags & 1) { |
793ee86a |
605 | /** |
606 | * Function is used as replacement in broken installs |
607 | * @ignore |
608 | */ |
a2a7852b |
609 | function _($str) { |
610 | return $str; |
611 | } |
612 | } |
613 | if (! $gettext_flags & 2) { |
793ee86a |
614 | /** |
615 | * Function is used as replacement in broken installs |
616 | * @ignore |
617 | */ |
a2a7852b |
618 | function bindtextdomain() { |
619 | return; |
620 | } |
621 | } |
622 | if (! $gettext_flags & 4) { |
793ee86a |
623 | /** |
624 | * Function is used as replacemet in broken installs |
625 | * @ignore |
626 | */ |
a2a7852b |
627 | function textdomain() { |
628 | return; |
629 | } |
630 | } |
631 | } |
632 | |
1d33e35e |
633 | |
51468260 |
634 | /** |
1d33e35e |
635 | * Japanese charset extra function |
636 | * |
51468260 |
637 | * Action performed by function is defined by first argument. |
638 | * Default return value is defined by second argument. |
639 | * Use of third argument depends on action. |
640 | * |
a8a1c36d |
641 | * @param string $action action performed by this function. |
51468260 |
642 | * possible values: |
643 | * decode - convert returned string to euc-jp. third argument unused |
644 | * encode - convert returned string to jis. third argument unused |
645 | * strimwidth - third argument=$width. trims string to $width symbols. |
646 | * encodeheader - create base64 encoded header in iso-2022-jp. third argument unused |
647 | * decodeheader - return human readable string from mime header. string is returned in euc-jp. third argument unused |
648 | * downloadfilename - third argument $useragent. Arguments provide browser info. Returns shift-jis or euc-jp encoded file name |
649 | * wordwrap - third argument=$wrap. wraps text at $wrap symbols |
650 | * utf7-imap_encode - returns string converted from euc-jp to utf7-imap. third argument unused |
651 | * utf7-imap_decode - returns string converted from utf7-imap to euc-jp. third argument unused |
a8a1c36d |
652 | * @param string $ret default return value |
1d33e35e |
653 | */ |
654 | function japanese_charset_xtra() { |
655 | $ret = func_get_arg(1); /* default return value */ |
656 | if (function_exists('mb_detect_encoding')) { |
657 | switch (func_get_arg(0)) { /* action */ |
658 | case 'decode': |
e842b215 |
659 | $detect_encoding = @mb_detect_encoding($ret); |
1d33e35e |
660 | if ($detect_encoding == 'JIS' || |
661 | $detect_encoding == 'EUC-JP' || |
e842b215 |
662 | $detect_encoding == 'SJIS' || |
663 | $detect_encoding == 'UTF-8') { |
1d33e35e |
664 | |
e842b215 |
665 | $ret = mb_convert_kana(mb_convert_encoding($ret, 'EUC-JP', 'AUTO'), "KV"); |
1d33e35e |
666 | } |
667 | break; |
668 | case 'encode': |
e842b215 |
669 | $detect_encoding = @mb_detect_encoding($ret); |
1d33e35e |
670 | if ($detect_encoding == 'JIS' || |
671 | $detect_encoding == 'EUC-JP' || |
e842b215 |
672 | $detect_encoding == 'SJIS' || |
673 | $detect_encoding == 'UTF-8') { |
1d33e35e |
674 | |
e842b215 |
675 | $ret = mb_convert_encoding(mb_convert_kana($ret, "KV"), 'JIS', 'AUTO'); |
1d33e35e |
676 | } |
677 | break; |
678 | case 'strimwidth': |
679 | $width = func_get_arg(2); |
680 | $ret = mb_strimwidth($ret, 0, $width, '...'); |
681 | break; |
682 | case 'encodeheader': |
8ba05cbe |
683 | $result = ''; |
684 | if (strlen($ret) > 0) { |
685 | $tmpstr = mb_substr($ret, 0, 1); |
686 | $prevcsize = strlen($tmpstr); |
687 | for ($i = 1; $i < mb_strlen($ret); $i++) { |
688 | $tmp = mb_substr($ret, $i, 1); |
689 | if (strlen($tmp) == $prevcsize) { |
690 | $tmpstr .= $tmp; |
691 | } else { |
692 | if ($prevcsize == 1) { |
693 | $result .= $tmpstr; |
694 | } else { |
e842b215 |
695 | $result .= str_replace(' ', '', |
696 | mb_encode_mimeheader($tmpstr,'iso-2022-jp','B','')); |
8ba05cbe |
697 | } |
698 | $tmpstr = $tmp; |
699 | $prevcsize = strlen($tmp); |
700 | } |
701 | } |
702 | if (strlen($tmpstr)) { |
703 | if (strlen(mb_substr($tmpstr, 0, 1)) == 1) |
704 | $result .= $tmpstr; |
705 | else |
e842b215 |
706 | $result .= str_replace(' ', '', |
707 | mb_encode_mimeheader($tmpstr,'iso-2022-jp','B','')); |
8ba05cbe |
708 | } |
709 | } |
710 | $ret = $result; |
1d33e35e |
711 | break; |
712 | case 'decodeheader': |
713 | $ret = str_replace("\t", "", $ret); |
714 | if (eregi('=\\?([^?]+)\\?(q|b)\\?([^?]+)\\?=', $ret)) |
e842b215 |
715 | $ret = @mb_decode_mimeheader($ret); |
716 | $ret = @mb_convert_encoding($ret, 'EUC-JP', 'AUTO'); |
1d33e35e |
717 | break; |
718 | case 'downloadfilename': |
719 | $useragent = func_get_arg(2); |
720 | if (strstr($useragent, 'Windows') !== false || |
721 | strstr($useragent, 'Mac_') !== false) { |
722 | $ret = mb_convert_encoding($ret, 'SJIS', 'AUTO'); |
723 | } else { |
724 | $ret = mb_convert_encoding($ret, 'EUC-JP', 'AUTO'); |
725 | } |
726 | break; |
e842b215 |
727 | case 'wordwrap': |
728 | $no_begin = "\x21\x25\x29\x2c\x2e\x3a\x3b\x3f\x5d\x7d\xa1\xf1\xa1\xeb\xa1" . |
729 | "\xc7\xa1\xc9\xa2\xf3\xa1\xec\xa1\xed\xa1\xee\xa1\xa2\xa1\xa3\xa1\xb9" . |
730 | "\xa1\xd3\xa1\xd5\xa1\xd7\xa1\xd9\xa1\xdb\xa1\xcd\xa4\xa1\xa4\xa3\xa4" . |
731 | "\xa5\xa4\xa7\xa4\xa9\xa4\xc3\xa4\xe3\xa4\xe5\xa4\xe7\xa4\xee\xa1\xab" . |
732 | "\xa1\xac\xa1\xb5\xa1\xb6\xa5\xa1\xa5\xa3\xa5\xa5\xa5\xa7\xa5\xa9\xa5" . |
733 | "\xc3\xa5\xe3\xa5\xe5\xa5\xe7\xa5\xee\xa5\xf5\xa5\xf6\xa1\xa6\xa1\xbc" . |
734 | "\xa1\xb3\xa1\xb4\xa1\xaa\xa1\xf3\xa1\xcb\xa1\xa4\xa1\xa5\xa1\xa7\xa1" . |
735 | "\xa8\xa1\xa9\xa1\xcf\xa1\xd1"; |
736 | $no_end = "\x5c\x24\x28\x5b\x7b\xa1\xf2\x5c\xa1\xc6\xa1\xc8\xa1\xd2\xa1" . |
737 | "\xd4\xa1\xd6\xa1\xd8\xa1\xda\xa1\xcc\xa1\xf0\xa1\xca\xa1\xce\xa1\xd0\xa1\xef"; |
738 | $wrap = func_get_arg(2); |
739 | |
740 | if (strlen($ret) >= $wrap && |
741 | substr($ret, 0, 1) != '>' && |
742 | strpos($ret, 'http://') === FALSE && |
743 | strpos($ret, 'https://') === FALSE && |
744 | strpos($ret, 'ftp://') === FALSE) { |
745 | |
746 | $ret = mb_convert_kana($ret, "KV"); |
747 | |
748 | $line_new = ''; |
749 | $ptr = 0; |
750 | |
751 | while ($ptr < strlen($ret) - 1) { |
752 | $l = mb_strcut($ret, $ptr, $wrap); |
753 | $ptr += strlen($l); |
754 | $tmp = $l; |
755 | |
756 | $l = mb_strcut($ret, $ptr, 2); |
757 | while (strlen($l) != 0 && mb_strpos($no_begin, $l) !== FALSE ) { |
758 | $tmp .= $l; |
759 | $ptr += strlen($l); |
760 | $l = mb_strcut($ret, $ptr, 1); |
761 | } |
762 | $line_new .= $tmp; |
763 | if ($ptr < strlen($ret) - 1) |
764 | $line_new .= "\n"; |
765 | } |
766 | $ret = $line_new; |
767 | } |
768 | break; |
769 | case 'utf7-imap_encode': |
770 | $ret = mb_convert_encoding($ret, 'UTF7-IMAP', 'EUC-JP'); |
771 | break; |
772 | case 'utf7-imap_decode': |
773 | $ret = mb_convert_encoding($ret, 'EUC-JP', 'UTF7-IMAP'); |
774 | break; |
1d33e35e |
775 | } |
776 | } |
777 | return $ret; |
778 | } |
779 | |
780 | |
51468260 |
781 | /** |
782 | * Korean charset extra functions |
783 | * |
784 | * Action performed by function is defined by first argument. |
785 | * Default return value is defined by second argument. |
786 | * |
787 | * @param string action performed by this function. |
788 | * possible values: |
789 | * downloadfilename - Hangul(Korean Character) Attached File Name Fix. |
790 | * @param string default return value |
1d33e35e |
791 | */ |
792 | function korean_charset_xtra() { |
793 | |
794 | $ret = func_get_arg(1); /* default return value */ |
795 | if (func_get_arg(0) == 'downloadfilename') { /* action */ |
796 | $ret = str_replace("\x0D\x0A", '', $ret); /* Hanmail's CR/LF Clear */ |
797 | for ($i=0;$i<strlen($ret);$i++) { |
798 | if ($ret[$i] >= "\xA1" && $ret[$i] <= "\xFE") { /* 0xA1 - 0XFE are Valid */ |
799 | $i++; |
800 | continue; |
801 | } else if (($ret[$i] >= 'a' && $ret[$i] <= 'z') || /* From Original ereg_replace in download.php */ |
802 | ($ret[$i] >= 'A' && $ret[$i] <= 'Z') || |
803 | ($ret[$i] == '.') || ($ret[$i] == '-')) { |
804 | continue; |
805 | } else { |
806 | $ret[$i] = '_'; |
807 | } |
808 | } |
809 | |
810 | } |
1d33e35e |
811 | return $ret; |
812 | } |
813 | |
db08d0c3 |
814 | /** |
815 | * Replaces non-braking spaces inserted by some browsers with regular space |
816 | * |
9af9c0a2 |
817 | * This function can be used to replace non-braking space symbols |
818 | * that are inserted in forms by some browsers instead of normal |
819 | * space symbol. |
db08d0c3 |
820 | * |
821 | * @param string $string Text that needs to be cleaned |
822 | * @param string $charset Charset used in text |
823 | * @return string Cleaned text |
9af9c0a2 |
824 | */ |
825 | function cleanup_nbsp($string,$charset) { |
826 | |
827 | // reduce number of case statements |
828 | if (stristr('iso-8859-',substr($charset,0,9))){ |
829 | $output_charset="iso-8859-x"; |
830 | } |
831 | if (stristr('windows-125',substr($charset,0,11))){ |
832 | $output_charset="cp125x"; |
833 | } |
834 | if (stristr('koi8',substr($charset,0,4))){ |
835 | $output_charset="koi8-x"; |
836 | } |
837 | if (! isset($output_charset)){ |
838 | $output_charset=strtolower($charset); |
839 | } |
840 | |
841 | // where is non-braking space symbol |
842 | switch($output_charset): |
843 | case "iso-8859-x": |
97b9c02f |
844 | case "cp125x": |
845 | case "iso-2022-jp": |
9af9c0a2 |
846 | $nbsp="\xA0"; |
847 | break; |
9af9c0a2 |
848 | case "koi8-x": |
849 | $nbsp="\x9A"; |
850 | break; |
851 | case "utf-8": |
852 | $nbsp="\xC2\xA0"; |
853 | break; |
9af9c0a2 |
854 | default: |
855 | // don't change string if charset is unmatched |
856 | return $string; |
857 | endswitch; |
858 | |
859 | // return space instead of non-braking space. |
860 | return str_replace($nbsp,' ',$string); |
861 | } |
4e519821 |
862 | |
db08d0c3 |
863 | /** |
864 | * Function informs if it is safe to convert given charset to the one that is used by user. |
865 | * |
866 | * It is safe to use conversion only if user uses utf-8 encoding and when |
867 | * converted charset is similar to the one that is used by user. |
868 | * |
869 | * @param string $input_charset Charset of text that needs to be converted |
870 | * @return bool is it possible to convert to user's charset |
871 | */ |
4e519821 |
872 | function is_conversion_safe($input_charset) { |
873 | global $languages, $sm_notAlias, $default_charset; |
874 | |
875 | // convert to lower case |
876 | $input_charset = strtolower($input_charset); |
877 | |
878 | // Is user's locale Unicode based ? |
879 | if ( $default_charset == "utf-8" ) { |
880 | return true; |
881 | } |
882 | |
883 | // Charsets that are similar |
884 | switch ($default_charset): |
885 | case "windows-1251": |
886 | if ( $input_charset == "iso-8859-5" || |
887 | $input_charset == "koi8-r" || |
888 | $input_charset == "koi8-u" ) { |
889 | return true; |
890 | } else { |
891 | return false; |
892 | } |
893 | case "windows-1257": |
894 | if ( $input_charset == "iso-8859-13" || |
895 | $input_charset == "iso-8859-4" ) { |
896 | return true; |
897 | } else { |
898 | return false; |
899 | } |
900 | case "iso-8859-4": |
901 | if ( $input_charset == "iso-8859-13" || |
902 | $input_charset == "windows-1257" ) { |
903 | return true; |
904 | } else { |
905 | return false; |
906 | } |
907 | case "iso-8859-5": |
908 | if ( $input_charset == "windows-1251" || |
909 | $input_charset == "koi8-r" || |
910 | $input_charset == "koi8-u" ) { |
911 | return true; |
912 | } else { |
913 | return false; |
914 | } |
915 | case "iso-8859-13": |
916 | if ( $input_charset == "iso-8859-4" || |
917 | $input_charset == "windows-1257" ) { |
918 | return true; |
919 | } else { |
920 | return false; |
921 | } |
922 | case "koi8-r": |
923 | if ( $input_charset == "windows-1251" || |
924 | $input_charset == "iso-8859-5" || |
925 | $input_charset == "koi8-u" ) { |
926 | return true; |
927 | } else { |
928 | return false; |
929 | } |
930 | case "koi8-u": |
931 | if ( $input_charset == "windows-1251" || |
932 | $input_charset == "iso-8859-5" || |
933 | $input_charset == "koi8-r" ) { |
934 | return true; |
935 | } else { |
936 | return false; |
937 | } |
938 | default: |
939 | return false; |
940 | endswitch; |
941 | } |
51468260 |
942 | ?> |