59177427 |
1 | <?php |
1fd97780 |
2 | |
35586184 |
3 | /** |
4 | * i18n.php |
5 | * |
76911253 |
6 | * Copyright (c) 1999-2003 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 | * |
15 | * $Id$ |
16 | */ |
17 | |
961ca3d8 |
18 | require_once(SM_PATH . 'functions/global.php'); |
19 | |
a2a7852b |
20 | /* Decodes a string to the internal encoding from the given charset */ |
21 | function charset_decode ($charset, $string) { |
6fbd125b |
22 | global $languages, $squirrelmail_language; |
a2a7852b |
23 | |
3714db45 |
24 | if (isset($languages[$squirrelmail_language]['XTRA_CODE']) && |
25 | function_exists($languages[$squirrelmail_language]['XTRA_CODE'])) { |
6fbd125b |
26 | $string = $languages[$squirrelmail_language]['XTRA_CODE']('decode', $string); |
27 | } |
b05c8961 |
28 | |
a2a7852b |
29 | /* All HTML special characters are 7 bit and can be replaced first */ |
cef054e4 |
30 | |
098ea084 |
31 | $string = htmlspecialchars ($string); |
a2a7852b |
32 | |
33 | $charset = strtolower($charset); |
34 | |
94965562 |
35 | set_my_charset() ; |
36 | |
a2a7852b |
37 | if (ereg('iso-8859-([[:digit:]]+)', $charset, $res)) { |
38 | if ($res[1] == '1') { |
39 | $ret = charset_decode_iso_8859_1 ($string); |
40 | } else if ($res[1] == '2') { |
41 | $ret = charset_decode_iso_8859_2 ($string); |
9be313d5 |
42 | } else if ($res[1] == '4') { |
43 | $ret = charset_decode_iso_8859_4 ($string); |
94965562 |
44 | } else if ($res[1] == '5') { |
45 | $ret = charset_decode_iso_8859_5 ($string); |
ef82d2d5 |
46 | } else if ($res[1] == '6') { |
47 | $ret = charset_decode_iso_8859_6 ($string); |
a2a7852b |
48 | } else if ($res[1] == '7') { |
49 | $ret = charset_decode_iso_8859_7 ($string); |
3ab35042 |
50 | } else if ($res[1] == '9') { |
51 | $ret = charset_decode_iso_8859_9 ($string); |
9be313d5 |
52 | } else if ($res[1] == '13') { |
53 | $ret = charset_decode_iso_8859_13 ($string); |
a2a7852b |
54 | } else if ($res[1] == '15') { |
55 | $ret = charset_decode_iso_8859_15 ($string); |
56 | } else { |
57 | $ret = charset_decode_iso_8859_default ($string); |
58 | } |
59 | } else if ($charset == 'ns_4551-1') { |
60 | $ret = charset_decode_ns_4551_1 ($string); |
61 | } else if ($charset == 'koi8-r') { |
62 | $ret = charset_decode_koi8r ($string); |
1c0e847f |
63 | } else if ($charset == 'koi8-u') { |
64 | $ret = charset_decode_koi8u ($string); |
a2a7852b |
65 | } else if ($charset == 'windows-1251') { |
ecd877a8 |
66 | $ret = charset_decode_windows_1251 ($string); |
3ab35042 |
67 | } else if ($charset == 'windows-1253') { |
68 | $ret = charset_decode_windows_1253 ($string); |
69 | } else if ($charset == 'windows-1254') { |
70 | $ret = charset_decode_windows_1254 ($string); |
c48a8ca7 |
71 | } else if ($charset == 'windows-1255') { |
72 | $ret = charset_decode_windows_1255 ($string); |
73 | } else if ($charset == 'windows-1256') { |
74 | $ret = charset_decode_windows_1256 ($string); |
c37a12f8 |
75 | } else if ($charset == 'windows-1257') { |
76 | $ret = charset_decode_windows_1257 ($string); |
3ab35042 |
77 | } else if ($charset == 'utf-8') { |
78 | $ret = charset_decode_utf8 ($string); |
a2a7852b |
79 | } else { |
80 | $ret = $string; |
81 | } |
82 | return( $ret ); |
83 | } |
84 | |
85 | /* |
86 | iso-8859-1 is the same as Latin 1 and is normally used |
87 | in western europe. |
88 | */ |
89 | function charset_decode_iso_8859_1 ($string) { |
90 | global $default_charset; |
13e0c649 |
91 | |
a2a7852b |
92 | if (strtolower($default_charset) <> 'iso-8859-1') { |
93 | /* Only do the slow convert if there are 8-bit characters */ |
94 | if (ereg("[\200-\377]", $string)) { |
066c374f |
95 | $string = str_replace("\201", '', $string); |
96 | $string = str_replace("\202", '‚', $string); |
97 | $string = str_replace("\203", 'ƒ', $string); |
98 | $string = str_replace("\204", '„', $string); |
99 | $string = str_replace("\205", '…', $string); |
100 | $string = str_replace("\206", '†', $string); |
101 | $string = str_replace("\207", '‡', $string); |
102 | $string = str_replace("\210", 'ˆ', $string); |
103 | $string = str_replace("\211", '‰', $string); |
104 | $string = str_replace("\212", 'Š', $string); |
105 | $string = str_replace("\213", '‹', $string); |
106 | $string = str_replace("\214", 'Œ', $string); |
107 | $string = str_replace("\215", '', $string); |
108 | $string = str_replace("\216", 'Ž', $string); |
109 | $string = str_replace("\217", '', $string); |
110 | $string = str_replace("\220", '', $string); |
111 | $string = str_replace("\221", '‘', $string); |
112 | $string = str_replace("\222", '’', $string); |
113 | $string = str_replace("\223", '“', $string); |
114 | $string = str_replace("\224", '”', $string); |
115 | $string = str_replace("\225", '•', $string); |
116 | $string = str_replace("\226", '–', $string); |
117 | $string = str_replace("\227", '—', $string); |
118 | $string = str_replace("\230", '˜', $string); |
119 | $string = str_replace("\231", '™', $string); |
120 | $string = str_replace("\232", 'š', $string); |
121 | $string = str_replace("\233", '›', $string); |
122 | $string = str_replace("\234", 'œ', $string); |
123 | $string = str_replace("\235", '', $string); |
124 | $string = str_replace("\236", 'ž', $string); |
125 | $string = str_replace("\237", 'Ÿ', $string); |
126 | $string = str_replace("\240", ' ', $string); |
127 | $string = str_replace("\241", '¡', $string); |
128 | $string = str_replace("\242", '¢', $string); |
129 | $string = str_replace("\243", '£', $string); |
130 | $string = str_replace("\244", '¤', $string); |
131 | $string = str_replace("\245", '¥', $string); |
132 | $string = str_replace("\246", '¦', $string); |
133 | $string = str_replace("\247", '§', $string); |
134 | $string = str_replace("\250", '¨', $string); |
135 | $string = str_replace("\251", '©', $string); |
136 | $string = str_replace("\252", 'ª', $string); |
137 | $string = str_replace("\253", '«', $string); |
138 | $string = str_replace("\254", '¬', $string); |
139 | $string = str_replace("\255", '­', $string); |
140 | $string = str_replace("\256", '®', $string); |
141 | $string = str_replace("\257", '¯', $string); |
142 | $string = str_replace("\260", '°', $string); |
143 | $string = str_replace("\261", '±', $string); |
144 | $string = str_replace("\262", '²', $string); |
145 | $string = str_replace("\263", '³', $string); |
146 | $string = str_replace("\264", '´', $string); |
147 | $string = str_replace("\265", 'µ', $string); |
148 | $string = str_replace("\266", '¶', $string); |
149 | $string = str_replace("\267", '·', $string); |
150 | $string = str_replace("\270", '¸', $string); |
151 | $string = str_replace("\271", '¹', $string); |
152 | $string = str_replace("\272", 'º', $string); |
153 | $string = str_replace("\273", '»', $string); |
154 | $string = str_replace("\274", '¼', $string); |
155 | $string = str_replace("\275", '½', $string); |
156 | $string = str_replace("\276", '¾', $string); |
157 | $string = str_replace("\277", '¿', $string); |
158 | $string = str_replace("\300", 'À', $string); |
159 | $string = str_replace("\301", 'Á', $string); |
160 | $string = str_replace("\302", 'Â', $string); |
161 | $string = str_replace("\303", 'Ã', $string); |
162 | $string = str_replace("\304", 'Ä', $string); |
163 | $string = str_replace("\305", 'Å', $string); |
164 | $string = str_replace("\306", 'Æ', $string); |
165 | $string = str_replace("\307", 'Ç', $string); |
166 | $string = str_replace("\310", 'È', $string); |
167 | $string = str_replace("\311", 'É', $string); |
168 | $string = str_replace("\312", 'Ê', $string); |
169 | $string = str_replace("\313", 'Ë', $string); |
170 | $string = str_replace("\314", 'Ì', $string); |
171 | $string = str_replace("\315", 'Í', $string); |
172 | $string = str_replace("\316", 'Î', $string); |
173 | $string = str_replace("\317", 'Ï', $string); |
174 | $string = str_replace("\320", 'Ð', $string); |
175 | $string = str_replace("\321", 'Ñ', $string); |
176 | $string = str_replace("\322", 'Ò', $string); |
177 | $string = str_replace("\323", 'Ó', $string); |
178 | $string = str_replace("\324", 'Ô', $string); |
179 | $string = str_replace("\325", 'Õ', $string); |
180 | $string = str_replace("\326", 'Ö', $string); |
181 | $string = str_replace("\327", '×', $string); |
182 | $string = str_replace("\330", 'Ø', $string); |
183 | $string = str_replace("\331", 'Ù', $string); |
184 | $string = str_replace("\332", 'Ú', $string); |
185 | $string = str_replace("\333", 'Û', $string); |
186 | $string = str_replace("\334", 'Ü', $string); |
187 | $string = str_replace("\335", 'Ý', $string); |
188 | $string = str_replace("\336", 'Þ', $string); |
189 | $string = str_replace("\337", 'ß', $string); |
190 | $string = str_replace("\340", 'à', $string); |
191 | $string = str_replace("\341", 'á', $string); |
192 | $string = str_replace("\342", 'â', $string); |
193 | $string = str_replace("\343", 'ã', $string); |
194 | $string = str_replace("\344", 'ä', $string); |
195 | $string = str_replace("\345", 'å', $string); |
196 | $string = str_replace("\346", 'æ', $string); |
197 | $string = str_replace("\347", 'ç', $string); |
198 | $string = str_replace("\350", 'è', $string); |
199 | $string = str_replace("\351", 'é', $string); |
200 | $string = str_replace("\352", 'ê', $string); |
201 | $string = str_replace("\353", 'ë', $string); |
202 | $string = str_replace("\354", 'ì', $string); |
203 | $string = str_replace("\355", 'í', $string); |
204 | $string = str_replace("\356", 'î', $string); |
205 | $string = str_replace("\357", 'ï', $string); |
206 | $string = str_replace("\360", 'ð', $string); |
207 | $string = str_replace("\361", 'ñ', $string); |
208 | $string = str_replace("\362", 'ò', $string); |
209 | $string = str_replace("\363", 'ó', $string); |
210 | $string = str_replace("\364", 'ô', $string); |
211 | $string = str_replace("\365", 'õ', $string); |
212 | $string = str_replace("\366", 'ö', $string); |
213 | $string = str_replace("\367", '÷', $string); |
214 | $string = str_replace("\370", 'ø', $string); |
215 | $string = str_replace("\371", 'ù', $string); |
216 | $string = str_replace("\372", 'ú', $string); |
217 | $string = str_replace("\373", 'û', $string); |
218 | $string = str_replace("\374", 'ü', $string); |
219 | $string = str_replace("\375", 'ý', $string); |
220 | $string = str_replace("\376", 'þ', $string); |
221 | $string = str_replace("\377", 'ÿ', $string); |
a2a7852b |
222 | } |
223 | } |
224 | |
225 | return ($string); |
226 | } |
227 | |
228 | /* iso-8859-2 is used for some eastern European languages */ |
229 | function charset_decode_iso_8859_2 ($string) { |
230 | global $default_charset; |
231 | |
232 | if (strtolower($default_charset) == 'iso-8859-2') |
233 | return $string; |
234 | |
235 | /* Only do the slow convert if there are 8-bit characters */ |
236 | if (! ereg("[\200-\377]", $string)) |
237 | return $string; |
238 | |
239 | /* NO-BREAK SPACE */ |
240 | $string = str_replace("\240", ' ', $string); |
241 | /* LATIN CAPITAL LETTER A WITH OGONEK */ |
242 | $string = str_replace("\241", 'Ą', $string); |
243 | /* BREVE */ |
244 | $string = str_replace("\242", '˘', $string); |
245 | // LATIN CAPITAL LETTER L WITH STROKE |
246 | $string = str_replace("\243", 'Ł', $string); |
247 | // CURRENCY SIGN |
248 | $string = str_replace("\244", '¤', $string); |
249 | // LATIN CAPITAL LETTER L WITH CARON |
250 | $string = str_replace("\245", 'Ľ', $string); |
251 | // LATIN CAPITAL LETTER S WITH ACUTE |
252 | $string = str_replace("\246", 'Ś', $string); |
253 | // SECTION SIGN |
254 | $string = str_replace("\247", '§', $string); |
255 | // DIAERESIS |
256 | $string = str_replace("\250", '¨', $string); |
257 | // LATIN CAPITAL LETTER S WITH CARON |
258 | $string = str_replace("\251", 'Š', $string); |
259 | // LATIN CAPITAL LETTER S WITH CEDILLA |
260 | $string = str_replace("\252", 'Ş', $string); |
261 | // LATIN CAPITAL LETTER T WITH CARON |
262 | $string = str_replace("\253", 'Ť', $string); |
263 | // LATIN CAPITAL LETTER Z WITH ACUTE |
264 | $string = str_replace("\254", 'Ź', $string); |
265 | // SOFT HYPHEN |
266 | $string = str_replace("\255", '­', $string); |
267 | // LATIN CAPITAL LETTER Z WITH CARON |
268 | $string = str_replace("\256", 'Ž', $string); |
269 | // LATIN CAPITAL LETTER Z WITH DOT ABOVE |
270 | $string = str_replace("\257", 'Ż', $string); |
271 | // DEGREE SIGN |
272 | $string = str_replace("\260", '°', $string); |
273 | // LATIN SMALL LETTER A WITH OGONEK |
274 | $string = str_replace("\261", 'ą', $string); |
275 | // OGONEK |
276 | $string = str_replace("\262", '˛', $string); |
277 | // LATIN SMALL LETTER L WITH STROKE |
278 | $string = str_replace("\263", 'ł', $string); |
279 | // ACUTE ACCENT |
280 | $string = str_replace("\264", '´', $string); |
281 | // LATIN SMALL LETTER L WITH CARON |
282 | $string = str_replace("\265", 'ľ', $string); |
283 | // LATIN SMALL LETTER S WITH ACUTE |
284 | $string = str_replace("\266", 'ś', $string); |
285 | // CARON |
286 | $string = str_replace("\267", 'ˇ', $string); |
287 | // CEDILLA |
288 | $string = str_replace("\270", '¸', $string); |
289 | // LATIN SMALL LETTER S WITH CARON |
290 | $string = str_replace("\271", 'š', $string); |
291 | // LATIN SMALL LETTER S WITH CEDILLA |
292 | $string = str_replace("\272", 'ş', $string); |
293 | // LATIN SMALL LETTER T WITH CARON |
294 | $string = str_replace("\273", 'ť', $string); |
295 | // LATIN SMALL LETTER Z WITH ACUTE |
296 | $string = str_replace("\274", 'ź', $string); |
297 | // DOUBLE ACUTE ACCENT |
298 | $string = str_replace("\275", '˝', $string); |
299 | // LATIN SMALL LETTER Z WITH CARON |
300 | $string = str_replace("\276", 'ž', $string); |
301 | // LATIN SMALL LETTER Z WITH DOT ABOVE |
302 | $string = str_replace("\277", 'ż', $string); |
303 | // LATIN CAPITAL LETTER R WITH ACUTE |
304 | $string = str_replace("\300", 'Ŕ', $string); |
305 | // LATIN CAPITAL LETTER A WITH ACUTE |
306 | $string = str_replace("\301", 'Á', $string); |
307 | // LATIN CAPITAL LETTER A WITH CIRCUMFLEX |
308 | $string = str_replace("\302", 'Â', $string); |
309 | // LATIN CAPITAL LETTER A WITH BREVE |
310 | $string = str_replace("\303", 'Ă', $string); |
311 | // LATIN CAPITAL LETTER A WITH DIAERESIS |
312 | $string = str_replace("\304", 'Ä', $string); |
313 | // LATIN CAPITAL LETTER L WITH ACUTE |
314 | $string = str_replace("\305", 'Ĺ', $string); |
315 | // LATIN CAPITAL LETTER C WITH ACUTE |
316 | $string = str_replace("\306", 'Ć', $string); |
317 | // LATIN CAPITAL LETTER C WITH CEDILLA |
318 | $string = str_replace("\307", 'Ç', $string); |
319 | // LATIN CAPITAL LETTER C WITH CARON |
320 | $string = str_replace("\310", 'Č', $string); |
321 | // LATIN CAPITAL LETTER E WITH ACUTE |
322 | $string = str_replace("\311", 'É', $string); |
323 | // LATIN CAPITAL LETTER E WITH OGONEK |
324 | $string = str_replace("\312", 'Ę', $string); |
325 | // LATIN CAPITAL LETTER E WITH DIAERESIS |
326 | $string = str_replace("\313", 'Ë', $string); |
327 | // LATIN CAPITAL LETTER E WITH CARON |
328 | $string = str_replace("\314", 'Ě', $string); |
329 | // LATIN CAPITAL LETTER I WITH ACUTE |
330 | $string = str_replace("\315", 'Í', $string); |
331 | // LATIN CAPITAL LETTER I WITH CIRCUMFLEX |
332 | $string = str_replace("\316", 'Î', $string); |
333 | // LATIN CAPITAL LETTER D WITH CARON |
334 | $string = str_replace("\317", 'Ď', $string); |
335 | // LATIN CAPITAL LETTER D WITH STROKE |
336 | $string = str_replace("\320", 'Đ', $string); |
337 | // LATIN CAPITAL LETTER N WITH ACUTE |
338 | $string = str_replace("\321", 'Ń', $string); |
339 | // LATIN CAPITAL LETTER N WITH CARON |
340 | $string = str_replace("\322", 'Ň', $string); |
341 | // LATIN CAPITAL LETTER O WITH ACUTE |
342 | $string = str_replace("\323", 'Ó', $string); |
343 | // LATIN CAPITAL LETTER O WITH CIRCUMFLEX |
344 | $string = str_replace("\324", 'Ô', $string); |
345 | // LATIN CAPITAL LETTER O WITH DOUBLE ACUTE |
346 | $string = str_replace("\325", 'Ő', $string); |
347 | // LATIN CAPITAL LETTER O WITH DIAERESIS |
348 | $string = str_replace("\326", 'Ö', $string); |
349 | // MULTIPLICATION SIGN |
350 | $string = str_replace("\327", '×', $string); |
351 | // LATIN CAPITAL LETTER R WITH CARON |
352 | $string = str_replace("\330", 'Ř', $string); |
353 | // LATIN CAPITAL LETTER U WITH RING ABOVE |
354 | $string = str_replace("\331", 'Ů', $string); |
355 | // LATIN CAPITAL LETTER U WITH ACUTE |
356 | $string = str_replace("\332", 'Ú', $string); |
357 | // LATIN CAPITAL LETTER U WITH DOUBLE ACUTE |
358 | $string = str_replace("\333", 'Ű', $string); |
359 | // LATIN CAPITAL LETTER U WITH DIAERESIS |
360 | $string = str_replace("\334", 'Ü', $string); |
361 | // LATIN CAPITAL LETTER Y WITH ACUTE |
362 | $string = str_replace("\335", 'Ý', $string); |
363 | // LATIN CAPITAL LETTER T WITH CEDILLA |
364 | $string = str_replace("\336", 'Ţ', $string); |
365 | // LATIN SMALL LETTER SHARP S |
366 | $string = str_replace("\337", 'ß', $string); |
367 | // LATIN SMALL LETTER R WITH ACUTE |
368 | $string = str_replace("\340", 'ŕ', $string); |
369 | // LATIN SMALL LETTER A WITH ACUTE |
370 | $string = str_replace("\341", 'á', $string); |
371 | // LATIN SMALL LETTER A WITH CIRCUMFLEX |
372 | $string = str_replace("\342", 'â', $string); |
373 | // LATIN SMALL LETTER A WITH BREVE |
374 | $string = str_replace("\343", 'ă', $string); |
375 | // LATIN SMALL LETTER A WITH DIAERESIS |
376 | $string = str_replace("\344", 'ä', $string); |
377 | // LATIN SMALL LETTER L WITH ACUTE |
378 | $string = str_replace("\345", 'ĺ', $string); |
379 | // LATIN SMALL LETTER C WITH ACUTE |
380 | $string = str_replace("\346", 'ć', $string); |
381 | // LATIN SMALL LETTER C WITH CEDILLA |
382 | $string = str_replace("\347", 'ç', $string); |
383 | // LATIN SMALL LETTER C WITH CARON |
384 | $string = str_replace("\350", 'č', $string); |
385 | // LATIN SMALL LETTER E WITH ACUTE |
386 | $string = str_replace("\351", 'é', $string); |
387 | // LATIN SMALL LETTER E WITH OGONEK |
388 | $string = str_replace("\352", 'ę', $string); |
389 | // LATIN SMALL LETTER E WITH DIAERESIS |
390 | $string = str_replace("\353", 'ë', $string); |
391 | // LATIN SMALL LETTER E WITH CARON |
392 | $string = str_replace("\354", 'ě', $string); |
393 | // LATIN SMALL LETTER I WITH ACUTE |
394 | $string = str_replace("\355", 'í', $string); |
395 | // LATIN SMALL LETTER I WITH CIRCUMFLEX |
396 | $string = str_replace("\356", 'î', $string); |
397 | // LATIN SMALL LETTER D WITH CARON |
398 | $string = str_replace("\357", 'ď', $string); |
399 | // LATIN SMALL LETTER D WITH STROKE |
400 | $string = str_replace("\360", 'đ', $string); |
401 | // LATIN SMALL LETTER N WITH ACUTE |
402 | $string = str_replace("\361", 'ń', $string); |
403 | // LATIN SMALL LETTER N WITH CARON |
404 | $string = str_replace("\362", 'ň', $string); |
405 | // LATIN SMALL LETTER O WITH ACUTE |
406 | $string = str_replace("\363", 'ó', $string); |
407 | // LATIN SMALL LETTER O WITH CIRCUMFLEX |
408 | $string = str_replace("\364", 'ô', $string); |
409 | // LATIN SMALL LETTER O WITH DOUBLE ACUTE |
410 | $string = str_replace("\365", 'ő', $string); |
411 | // LATIN SMALL LETTER O WITH DIAERESIS |
412 | $string = str_replace("\366", 'ö', $string); |
413 | // DIVISION SIGN |
414 | $string = str_replace("\367", '÷', $string); |
415 | // LATIN SMALL LETTER R WITH CARON |
416 | $string = str_replace("\370", 'ř', $string); |
417 | // LATIN SMALL LETTER U WITH RING ABOVE |
418 | $string = str_replace("\371", 'ů', $string); |
419 | // LATIN SMALL LETTER U WITH ACUTE |
420 | $string = str_replace("\372", 'ú', $string); |
421 | // LATIN SMALL LETTER U WITH DOUBLE ACUTE |
422 | $string = str_replace("\373", 'ű', $string); |
423 | // LATIN SMALL LETTER U WITH DIAERESIS |
424 | $string = str_replace("\374", 'ü', $string); |
425 | // LATIN SMALL LETTER Y WITH ACUTE |
426 | $string = str_replace("\375", 'ý', $string); |
427 | // LATIN SMALL LETTER T WITH CEDILLA |
428 | $string = str_replace("\376", 'ţ', $string); |
429 | // DOT ABOVE |
430 | $string = str_replace("\377", '˙', $string); |
431 | |
432 | return $string; |
433 | } |
434 | |
9be313d5 |
435 | /* |
c37a12f8 |
436 | ISO/IEC 8859-4:1998 Latin Alphabet No. 4 |
9be313d5 |
437 | */ |
438 | |
439 | function charset_decode_iso_8859_4 ($string) { |
94965562 |
440 | global $default_charset; |
9be313d5 |
441 | |
c37a12f8 |
442 | if (strtolower($default_charset) == 'iso-8859-4') |
443 | return $string; |
c37a12f8 |
444 | |
445 | /* Only do the slow convert if there are 8-bit characters */ |
446 | if (! ereg("[\200-\377]", $string)) |
447 | return $string; |
448 | |
c37a12f8 |
449 | $string = str_replace ("\241", 'Ą', $string); |
c37a12f8 |
450 | $string = str_replace ("\242", 'ĸ', $string); |
c37a12f8 |
451 | $string = str_replace ("\243", 'Ŗ', $string); |
c37a12f8 |
452 | $string = str_replace ("\245", 'Ĩ', $string); |
c37a12f8 |
453 | $string = str_replace ("\246", 'Ļ', $string); |
c37a12f8 |
454 | $string = str_replace ("\251", 'Š', $string); |
c37a12f8 |
455 | $string = str_replace ("\252", 'Ē', $string); |
c37a12f8 |
456 | $string = str_replace ("\253", 'Ģ', $string); |
c37a12f8 |
457 | $string = str_replace ("\254", 'Ŧ', $string); |
c37a12f8 |
458 | $string = str_replace ("\256", 'Ž', $string); |
c37a12f8 |
459 | $string = str_replace ("\261", 'ą', $string); |
c37a12f8 |
460 | $string = str_replace ("\262", '˛', $string); |
c37a12f8 |
461 | $string = str_replace ("\263", 'ŗ', $string); |
c37a12f8 |
462 | $string = str_replace ("\265", 'ĩ', $string); |
c37a12f8 |
463 | $string = str_replace ("\266", 'ļ', $string); |
c37a12f8 |
464 | $string = str_replace ("\267", 'ˇ', $string); |
c37a12f8 |
465 | $string = str_replace ("\271", 'š', $string); |
c37a12f8 |
466 | $string = str_replace ("\272", 'ē', $string); |
c37a12f8 |
467 | $string = str_replace ("\273", 'ģ', $string); |
c37a12f8 |
468 | $string = str_replace ("\274", 'ŧ', $string); |
c37a12f8 |
469 | $string = str_replace ("\275", 'Ŋ', $string); |
c37a12f8 |
470 | $string = str_replace ("\276", 'ž', $string); |
c37a12f8 |
471 | $string = str_replace ("\277", 'ŋ', $string); |
c37a12f8 |
472 | $string = str_replace ("\300", 'Ā', $string); |
c37a12f8 |
473 | $string = str_replace ("\307", 'Į', $string); |
c37a12f8 |
474 | $string = str_replace ("\310", 'Č', $string); |
c37a12f8 |
475 | $string = str_replace ("\312", 'Ę', $string); |
c37a12f8 |
476 | $string = str_replace ("\314", 'Ė', $string); |
c37a12f8 |
477 | $string = str_replace ("\317", 'Ī', $string); |
c37a12f8 |
478 | $string = str_replace ("\320", 'Đ', $string); |
c37a12f8 |
479 | $string = str_replace ("\321", 'Ņ', $string); |
c37a12f8 |
480 | $string = str_replace ("\322", 'Ō', $string); |
c37a12f8 |
481 | $string = str_replace ("\323", 'Ķ', $string); |
c37a12f8 |
482 | $string = str_replace ("\331", 'Ų', $string); |
c37a12f8 |
483 | $string = str_replace ("\335", 'Ũ', $string); |
c37a12f8 |
484 | $string = str_replace ("\336", 'Ū', $string); |
c37a12f8 |
485 | $string = str_replace ("\340", 'ā', $string); |
c37a12f8 |
486 | $string = str_replace ("\347", 'į', $string); |
c37a12f8 |
487 | $string = str_replace ("\350", 'č', $string); |
c37a12f8 |
488 | $string = str_replace ("\352", 'ę', $string); |
c37a12f8 |
489 | $string = str_replace ("\354", 'ė', $string); |
c37a12f8 |
490 | $string = str_replace ("\357", 'ī', $string); |
c37a12f8 |
491 | $string = str_replace ("\360", 'đ', $string); |
c37a12f8 |
492 | $string = str_replace ("\361", 'ņ', $string); |
c37a12f8 |
493 | $string = str_replace ("\362", 'ō', $string); |
c37a12f8 |
494 | $string = str_replace ("\363", 'ķ', $string); |
c37a12f8 |
495 | $string = str_replace ("\371", 'ų', $string); |
c37a12f8 |
496 | $string = str_replace ("\375", 'ũ', $string); |
c37a12f8 |
497 | $string = str_replace ("\376", 'ū', $string); |
c37a12f8 |
498 | $string = str_replace ("\377", '˙', $string); |
499 | |
500 | // rest of charset is the same as ISO-8859-1 |
9be313d5 |
501 | return (charset_decode_iso_8859_1($string)); |
502 | } |
503 | |
1c0e847f |
504 | /* ISO-8859-5 is Cyrillic */ |
505 | function charset_decode_iso_8859_5 ($string) { |
506 | global $default_charset; |
507 | |
508 | if (strtolower($default_charset) == 'iso-8859-5') { |
509 | return $string; |
510 | } |
511 | |
512 | /* Only do the slow convert if there are 8-bit characters */ |
513 | if (! ereg("[\200-\377]", $string)) |
514 | return $string; |
515 | |
516 | // NO-BREAK SPACE |
517 | $string = str_replace("\240", ' ', $string); |
518 | // 161-172 -> 1025-1036 (+864) |
519 | $string = preg_replace("/([\241-\254])/e","'&#' . (ord('\\1')+864) . ';'",$string); |
520 | // SOFT HYPHEN |
521 | $string = str_replace("\255", '­', $string); |
522 | // 174-239 -> 1038-1103 (+864) |
523 | $string = preg_replace("/([\256-\357])/e","'&#' . (ord('\\1')+864) . ';'",$string); |
524 | // NUMERO SIGN |
525 | $string = str_replace("\360", '№', $string); |
526 | // 241-252 -> 1105-1116 (+864) |
527 | $string = preg_replace("/([\361-\374])/e","'&#' . (ord('\\1')+864) . ';'",$string); |
528 | // SECTION SIGN |
529 | $string = str_replace("\375", '§', $string); |
530 | // CYRILLIC SMALL LETTER SHORT U (Byelorussian) |
531 | $string = str_replace("\376", 'ў', $string); |
532 | // CYRILLIC SMALL LETTER DZHE |
533 | $string = str_replace("\377", 'џ', $string); |
534 | |
535 | return $string; |
536 | } |
537 | |
ef82d2d5 |
538 | /* |
539 | ISO/IEC 8859-6:1999 Latin/Arabic Alphabet |
540 | */ |
541 | function charset_decode_iso_8859_6 ($string) { |
542 | global $default_charset; |
543 | |
544 | if (strtolower($default_charset) == 'iso-8859-6') |
545 | return $string; |
546 | |
547 | /* Only do the slow convert if there are 8-bit characters */ |
548 | if (! ereg("[\200-\377]", $string)) |
549 | return $string; |
550 | |
551 | $string = str_replace ("\240", ' ', $string); |
552 | $string = str_replace ("\244", '¤', $string); |
553 | $string = str_replace ("\254", '،', $string); |
554 | $string = str_replace ("\255", '­', $string); |
555 | $string = str_replace ("\273", '؛', $string); |
556 | $string = str_replace ("\277", '؟', $string); |
557 | // 193-218 -> 1569-1594 (+1376) |
558 | $string = preg_replace("/([\301-\332])/e","'&#' . (ord('\\1')+1376).';'",$string); |
559 | // 224-242 -> 1600-1618 (+1376) |
560 | $string = preg_replace("/([\340-\362])/e","'&#' . (ord('\\1')+1376).';'",$string); |
561 | |
562 | return ($string); |
563 | } |
564 | |
a2a7852b |
565 | /* iso-8859-7 is Greek. */ |
566 | function charset_decode_iso_8859_7 ($string) { |
567 | global $default_charset; |
568 | |
569 | if (strtolower($default_charset) == 'iso-8859-7') { |
570 | return $string; |
571 | } |
572 | |
573 | /* Only do the slow convert if there are 8-bit characters */ |
574 | if (!ereg("[\200-\377]", $string)) { |
575 | return $string; |
576 | } |
577 | |
578 | /* Some diverse characters in the beginning */ |
579 | $string = str_replace("\240", ' ', $string); |
580 | $string = str_replace("\241", '‘', $string); |
581 | $string = str_replace("\242", '’', $string); |
582 | $string = str_replace("\243", '£', $string); |
583 | $string = str_replace("\246", '¦', $string); |
584 | $string = str_replace("\247", '§', $string); |
585 | $string = str_replace("\250", '¨', $string); |
586 | $string = str_replace("\251", '©', $string); |
587 | $string = str_replace("\253", '«', $string); |
588 | $string = str_replace("\254", '¬', $string); |
589 | $string = str_replace("\255", '­', $string); |
590 | $string = str_replace("\257", '―', $string); |
591 | $string = str_replace("\260", '°', $string); |
592 | $string = str_replace("\261", '±', $string); |
593 | $string = str_replace("\262", '²', $string); |
594 | $string = str_replace("\263", '³', $string); |
595 | |
596 | /* Horizontal bar (parentheki pavla) */ |
597 | $string = str_replace ("\257", '―', $string); |
598 | |
599 | /* |
600 | * ISO-8859-7 characters from 11/04 (0xB4) to 11/06 (0xB6) |
601 | * These are Unicode 900-902 |
602 | */ |
b85a4575 |
603 | $string = preg_replace("/([\264-\266])/e","'&#' . (ord('\\1')+720);",$string); |
49c17806 |
604 | |
a2a7852b |
605 | /* 11/07 (0xB7) Middle dot is the same in iso-8859-1 */ |
606 | $string = str_replace("\267", '·', $string); |
607 | |
608 | /* |
609 | * ISO-8859-7 characters from 11/08 (0xB8) to 11/10 (0xBA) |
610 | * These are Unicode 900-902 |
611 | */ |
b85a4575 |
612 | $string = preg_replace("/([\270-\272])/e","'&#' . (ord('\\1')+720);",$string); |
a2a7852b |
613 | |
614 | /* |
615 | * 11/11 (0xBB) Right angle quotation mark is the same as in |
616 | * iso-8859-1 |
617 | */ |
618 | $string = str_replace("\273", '»', $string); |
619 | |
620 | /* And now the rest of the charset */ |
b85a4575 |
621 | $string = preg_replace("/([\274-\376])/e","'&#'.(ord('\\1')+720);",$string); |
a2a7852b |
622 | |
623 | return $string; |
624 | } |
625 | |
626 | /* |
cd21d1aa |
627 | ISOIEC 8859-9:1999 Latin Alphabet No. 5 |
961ca3d8 |
628 | |
3ab35042 |
629 | */ |
630 | function charset_decode_iso_8859_9 ($string) { |
94965562 |
631 | global $default_charset; |
3ab35042 |
632 | |
633 | if (strtolower($default_charset) == 'iso-8859-9') |
634 | return $string; |
3ab35042 |
635 | |
636 | /* Only do the slow convert if there are 8-bit characters */ |
637 | if (! ereg("[\200-\377]", $string)) |
638 | return $string; |
639 | |
640 | // latin capital letter g with breve 208->286 |
641 | $string = str_replace("\320", 'Ğ', $string); |
642 | // latin capital letter i with dot above 221->304 |
643 | $string = str_replace("\335", 'İ', $string); |
644 | // latin capital letter s with cedilla 222->350 |
645 | $string = str_replace("\336", 'Ş', $string); |
646 | // latin small letter g with breve 240->287 |
647 | $string = str_replace("\360", 'ğ', $string); |
648 | // latin small letter dotless i 253->305 |
649 | $string = str_replace("\375", 'ı', $string); |
650 | // latin small letter s with cedilla 254->351 |
651 | $string = str_replace("\376", 'ş', $string); |
652 | |
653 | // rest of charset is the same as ISO-8859-1 |
654 | return (charset_decode_iso_8859_1($string)); |
655 | } |
656 | |
657 | |
658 | /* |
c37a12f8 |
659 | ISO/IEC 8859-13:1998 Latin Alphabet No. 7 (Baltic Rim) |
9be313d5 |
660 | */ |
9be313d5 |
661 | function charset_decode_iso_8859_13 ($string) { |
94965562 |
662 | global $default_charset; |
c37a12f8 |
663 | |
664 | if (strtolower($default_charset) == 'iso-8859-13') |
665 | return $string; |
c37a12f8 |
666 | |
667 | /* Only do the slow convert if there are 8-bit characters */ |
668 | if (! ereg("[\200-\377]", $string)) |
669 | return $string; |
9be313d5 |
670 | |
c37a12f8 |
671 | $string = str_replace ("\241", '”', $string); |
c37a12f8 |
672 | $string = str_replace ("\245", '„', $string); |
c37a12f8 |
673 | $string = str_replace ("\250", 'Ø', $string); |
c37a12f8 |
674 | $string = str_replace ("\252", 'Ŗ', $string); |
c37a12f8 |
675 | $string = str_replace ("\257", 'Æ', $string); |
c37a12f8 |
676 | $string = str_replace ("\264", '“', $string); |
c37a12f8 |
677 | $string = str_replace ("\270", 'ø', $string); |
c37a12f8 |
678 | $string = str_replace ("\272", 'ŗ', $string); |
c37a12f8 |
679 | $string = str_replace ("\277", 'æ', $string); |
c37a12f8 |
680 | $string = str_replace ("\300", 'Ą', $string); |
c37a12f8 |
681 | $string = str_replace ("\301", 'Į', $string); |
c37a12f8 |
682 | $string = str_replace ("\302", 'Ā', $string); |
c37a12f8 |
683 | $string = str_replace ("\303", 'Ć', $string); |
c37a12f8 |
684 | $string = str_replace ("\306", 'Ę', $string); |
c37a12f8 |
685 | $string = str_replace ("\307", 'Ē', $string); |
c37a12f8 |
686 | $string = str_replace ("\310", 'Č', $string); |
c37a12f8 |
687 | $string = str_replace ("\312", 'Ź', $string); |
c37a12f8 |
688 | $string = str_replace ("\313", 'Ė', $string); |
c37a12f8 |
689 | $string = str_replace ("\314", 'Ģ', $string); |
c37a12f8 |
690 | $string = str_replace ("\315", 'Ķ', $string); |
c37a12f8 |
691 | $string = str_replace ("\316", 'Ī', $string); |
c37a12f8 |
692 | $string = str_replace ("\317", 'Ļ', $string); |
c37a12f8 |
693 | $string = str_replace ("\320", 'Š', $string); |
c37a12f8 |
694 | $string = str_replace ("\321", 'Ń', $string); |
c37a12f8 |
695 | $string = str_replace ("\322", 'Ņ', $string); |
c37a12f8 |
696 | $string = str_replace ("\324", 'Ō', $string); |
c37a12f8 |
697 | $string = str_replace ("\330", 'Ų', $string); |
c37a12f8 |
698 | $string = str_replace ("\331", 'Ł', $string); |
c37a12f8 |
699 | $string = str_replace ("\332", 'Ś', $string); |
c37a12f8 |
700 | $string = str_replace ("\333", 'Ū', $string); |
c37a12f8 |
701 | $string = str_replace ("\335", 'Ż', $string); |
c37a12f8 |
702 | $string = str_replace ("\336", 'Ž', $string); |
c37a12f8 |
703 | $string = str_replace ("\340", 'ą', $string); |
c37a12f8 |
704 | $string = str_replace ("\341", 'į', $string); |
c37a12f8 |
705 | $string = str_replace ("\342", 'ā', $string); |
c37a12f8 |
706 | $string = str_replace ("\343", 'ć', $string); |
c37a12f8 |
707 | $string = str_replace ("\346", 'ę', $string); |
c37a12f8 |
708 | $string = str_replace ("\347", 'ē', $string); |
c37a12f8 |
709 | $string = str_replace ("\350", 'č', $string); |
c37a12f8 |
710 | $string = str_replace ("\352", 'ź', $string); |
c37a12f8 |
711 | $string = str_replace ("\353", 'ė', $string); |
c37a12f8 |
712 | $string = str_replace ("\354", 'ģ', $string); |
c37a12f8 |
713 | $string = str_replace ("\355", 'ķ', $string); |
c37a12f8 |
714 | $string = str_replace ("\356", 'ī', $string); |
c37a12f8 |
715 | $string = str_replace ("\357", 'ļ', $string); |
c37a12f8 |
716 | $string = str_replace ("\360", 'š', $string); |
c37a12f8 |
717 | $string = str_replace ("\361", 'ń', $string); |
c37a12f8 |
718 | $string = str_replace ("\362", 'ņ', $string); |
c37a12f8 |
719 | $string = str_replace ("\364", 'ō', $string); |
c37a12f8 |
720 | $string = str_replace ("\370", 'ų', $string); |
c37a12f8 |
721 | $string = str_replace ("\371", 'ł', $string); |
c37a12f8 |
722 | $string = str_replace ("\372", 'ś', $string); |
c37a12f8 |
723 | $string = str_replace ("\373", 'ū', $string); |
c37a12f8 |
724 | $string = str_replace ("\375", 'ż', $string); |
c37a12f8 |
725 | $string = str_replace ("\376", 'ž', $string); |
c37a12f8 |
726 | $string = str_replace ("\377", '’', $string); |
727 | |
728 | // rest of charset is the same as ISO-8859-1 |
9be313d5 |
729 | return (charset_decode_iso_8859_1($string)); |
730 | } |
731 | |
732 | /* |
a2a7852b |
733 | * iso-8859-15 is Latin 9 and has very much the same use as Latin 1 |
734 | * but has the Euro symbol and some characters needed for French. |
735 | */ |
736 | function charset_decode_iso_8859_15 ($string) { |
737 | // Euro sign |
738 | $string = str_replace ("\244", '€', $string); |
739 | // Latin capital letter S with caron |
84556805 |
740 | $string = str_replace ("\246", 'Š', $string); |
a2a7852b |
741 | // Latin small letter s with caron |
742 | $string = str_replace ("\250", 'š', $string); |
743 | // Latin capital letter Z with caron |
744 | $string = str_replace ("\264", 'Ž', $string); |
745 | // Latin small letter z with caron |
746 | $string = str_replace ("\270", 'ž', $string); |
747 | // Latin capital ligature OE |
748 | $string = str_replace ("\274", 'Œ', $string); |
749 | // Latin small ligature oe |
750 | $string = str_replace ("\275", 'œ', $string); |
751 | // Latin capital letter Y with diaeresis |
752 | $string = str_replace ("\276", 'Ÿ', $string); |
753 | |
754 | return (charset_decode_iso_8859_1($string)); |
755 | } |
756 | |
a2a7852b |
757 | |
758 | /* Remove all 8 bit characters from all other ISO-8859 character sets */ |
759 | function charset_decode_iso_8859_default ($string) { |
760 | return (strtr($string, "\240\241\242\243\244\245\246\247". |
1fd97780 |
761 | "\250\251\252\253\254\255\256\257". |
762 | "\260\261\262\263\264\265\266\267". |
763 | "\270\271\272\273\274\275\276\277". |
764 | "\300\301\302\303\304\305\306\307". |
765 | "\310\311\312\313\314\315\316\317". |
766 | "\320\321\322\323\324\325\326\327". |
767 | "\330\331\332\333\334\335\336\337". |
768 | "\340\341\342\343\344\345\346\347". |
769 | "\350\351\352\353\354\355\356\357". |
770 | "\360\361\362\363\364\365\366\367". |
a2a7852b |
771 | "\370\371\372\373\374\375\376\377", |
1fd97780 |
772 | "????????????????????????????????????????". |
773 | "????????????????????????????????????????". |
774 | "????????????????????????????????????????". |
775 | "????????")); |
a2a7852b |
776 | |
777 | } |
778 | |
779 | /* |
780 | * This is the same as ISO-646-NO and is used by some |
781 | * Microsoft programs when sending Norwegian characters |
782 | */ |
783 | function charset_decode_ns_4551_1 ($string) { |
784 | /* |
785 | * These characters are: |
786 | * Latin capital letter AE |
787 | * Latin capital letter O with stroke |
788 | * Latin capital letter A with ring above |
789 | * and the same as small letters |
790 | */ |
791 | return strtr ($string, "[\\]{|}", "ÆØÅæøå"); |
792 | } |
793 | |
794 | /* |
795 | * KOI8-R is used to encode Russian mail (Cyrrilic). Defined in RFC |
796 | * 1489. |
797 | */ |
798 | function charset_decode_koi8r ($string) { |
799 | global $default_charset; |
800 | |
801 | if ($default_charset == 'koi8-r') { |
802 | return $string; |
803 | } |
804 | |
805 | /* |
806 | * Convert to Unicode HTML entities. |
807 | * This code is rather ineffective. |
808 | */ |
809 | $string = str_replace("\200", '─', $string); |
810 | $string = str_replace("\201", '│', $string); |
811 | $string = str_replace("\202", '┌', $string); |
812 | $string = str_replace("\203", '┐', $string); |
813 | $string = str_replace("\204", '└', $string); |
814 | $string = str_replace("\205", '┘', $string); |
815 | $string = str_replace("\206", '├', $string); |
816 | $string = str_replace("\207", '┤', $string); |
817 | $string = str_replace("\210", '┬', $string); |
818 | $string = str_replace("\211", '┴', $string); |
819 | $string = str_replace("\212", '┼', $string); |
820 | $string = str_replace("\213", '▀', $string); |
821 | $string = str_replace("\214", '▄', $string); |
822 | $string = str_replace("\215", '█', $string); |
823 | $string = str_replace("\216", '▌', $string); |
824 | $string = str_replace("\217", '▐', $string); |
825 | $string = str_replace("\220", '░', $string); |
826 | $string = str_replace("\221", '▒', $string); |
827 | $string = str_replace("\222", '▓', $string); |
828 | $string = str_replace("\223", '⌠', $string); |
829 | $string = str_replace("\224", '■', $string); |
830 | $string = str_replace("\225", '∙', $string); |
831 | $string = str_replace("\226", '√', $string); |
832 | $string = str_replace("\227", '≈', $string); |
833 | $string = str_replace("\230", '≤', $string); |
834 | $string = str_replace("\231", '≥', $string); |
835 | $string = str_replace("\232", ' ', $string); |
836 | $string = str_replace("\233", '⌡', $string); |
837 | $string = str_replace("\234", '°', $string); |
838 | $string = str_replace("\235", '²', $string); |
839 | $string = str_replace("\236", '·', $string); |
840 | $string = str_replace("\237", '÷', $string); |
841 | $string = str_replace("\240", '═', $string); |
842 | $string = str_replace("\241", '║', $string); |
843 | $string = str_replace("\242", '╒', $string); |
844 | $string = str_replace("\243", 'ё', $string); |
845 | $string = str_replace("\244", '╓', $string); |
846 | $string = str_replace("\245", '╔', $string); |
847 | $string = str_replace("\246", '╕', $string); |
848 | $string = str_replace("\247", '╖', $string); |
849 | $string = str_replace("\250", '╗', $string); |
850 | $string = str_replace("\251", '╘', $string); |
851 | $string = str_replace("\252", '╙', $string); |
852 | $string = str_replace("\253", '╚', $string); |
853 | $string = str_replace("\254", '╛', $string); |
854 | $string = str_replace("\255", '╜', $string); |
855 | $string = str_replace("\256", '╝', $string); |
856 | $string = str_replace("\257", '╞', $string); |
857 | $string = str_replace("\260", '╟', $string); |
858 | $string = str_replace("\261", '╠', $string); |
859 | $string = str_replace("\262", '╡', $string); |
860 | $string = str_replace("\263", 'Ё', $string); |
861 | $string = str_replace("\264", '╢', $string); |
862 | $string = str_replace("\265", '╣', $string); |
863 | $string = str_replace("\266", '╤', $string); |
864 | $string = str_replace("\267", '╥', $string); |
865 | $string = str_replace("\270", '╦', $string); |
866 | $string = str_replace("\271", '╧', $string); |
867 | $string = str_replace("\272", '╨', $string); |
868 | $string = str_replace("\273", '╩', $string); |
869 | $string = str_replace("\274", '╪', $string); |
870 | $string = str_replace("\275", '╫', $string); |
871 | $string = str_replace("\276", '╬', $string); |
872 | $string = str_replace("\277", '©', $string); |
873 | $string = str_replace("\300", 'ю', $string); |
874 | $string = str_replace("\301", 'а', $string); |
875 | $string = str_replace("\302", 'б', $string); |
876 | $string = str_replace("\303", 'ц', $string); |
877 | $string = str_replace("\304", 'д', $string); |
878 | $string = str_replace("\305", 'е', $string); |
879 | $string = str_replace("\306", 'ф', $string); |
880 | $string = str_replace("\307", 'г', $string); |
881 | $string = str_replace("\310", 'х', $string); |
882 | $string = str_replace("\311", 'и', $string); |
883 | $string = str_replace("\312", 'й', $string); |
884 | $string = str_replace("\313", 'к', $string); |
885 | $string = str_replace("\314", 'л', $string); |
886 | $string = str_replace("\315", 'м', $string); |
887 | $string = str_replace("\316", 'н', $string); |
888 | $string = str_replace("\317", 'о', $string); |
889 | $string = str_replace("\320", 'п', $string); |
890 | $string = str_replace("\321", 'я', $string); |
891 | $string = str_replace("\322", 'р', $string); |
892 | $string = str_replace("\323", 'с', $string); |
893 | $string = str_replace("\324", 'т', $string); |
894 | $string = str_replace("\325", 'у', $string); |
895 | $string = str_replace("\326", 'ж', $string); |
896 | $string = str_replace("\327", 'в', $string); |
897 | $string = str_replace("\330", 'ь', $string); |
898 | $string = str_replace("\331", 'ы', $string); |
899 | $string = str_replace("\332", 'з', $string); |
900 | $string = str_replace("\333", 'ш', $string); |
901 | $string = str_replace("\334", 'э', $string); |
902 | $string = str_replace("\335", 'щ', $string); |
903 | $string = str_replace("\336", 'ч', $string); |
904 | $string = str_replace("\337", 'ъ', $string); |
905 | $string = str_replace("\340", 'Ю', $string); |
906 | $string = str_replace("\341", 'А', $string); |
907 | $string = str_replace("\342", 'Б', $string); |
908 | $string = str_replace("\343", 'Ц', $string); |
909 | $string = str_replace("\344", 'Д', $string); |
910 | $string = str_replace("\345", 'Е', $string); |
911 | $string = str_replace("\346", 'Ф', $string); |
912 | $string = str_replace("\347", 'Г', $string); |
913 | $string = str_replace("\350", 'Х', $string); |
914 | $string = str_replace("\351", 'И', $string); |
915 | $string = str_replace("\352", 'Й', $string); |
916 | $string = str_replace("\353", 'К', $string); |
917 | $string = str_replace("\354", 'Л', $string); |
918 | $string = str_replace("\355", 'М', $string); |
919 | $string = str_replace("\356", 'Н', $string); |
920 | $string = str_replace("\357", 'О', $string); |
921 | $string = str_replace("\360", 'П', $string); |
922 | $string = str_replace("\361", 'Я', $string); |
923 | $string = str_replace("\362", 'Р', $string); |
924 | $string = str_replace("\363", 'С', $string); |
925 | $string = str_replace("\364", 'Т', $string); |
926 | $string = str_replace("\365", 'У', $string); |
927 | $string = str_replace("\366", 'Ж', $string); |
928 | $string = str_replace("\367", 'В', $string); |
929 | $string = str_replace("\370", 'Ь', $string); |
930 | $string = str_replace("\371", 'Ы', $string); |
931 | $string = str_replace("\372", 'З', $string); |
932 | $string = str_replace("\373", 'Ш', $string); |
933 | $string = str_replace("\374", 'Э', $string); |
934 | $string = str_replace("\375", 'Щ', $string); |
935 | $string = str_replace("\376", 'Ч', $string); |
936 | $string = str_replace("\377", 'Ъ', $string); |
937 | |
938 | return $string; |
939 | } |
940 | |
c37a12f8 |
941 | /* |
1c0e847f |
942 | * KOI8-U is used to encode Ukrainian mail (Cyrrilic). Defined in RFC |
943 | * 2319. |
944 | */ |
945 | function charset_decode_koi8u ($string) { |
946 | global $default_charset; |
947 | |
948 | if (strtolower($default_charset) == 'koi8-u') { |
949 | return $string; |
950 | } |
951 | |
952 | /* Only do the slow convert if there are 8-bit characters */ |
953 | if (! ereg("[\200-\377]", $string)) |
954 | return $string; |
955 | |
956 | // BOX DRAWINGS LIGHT HORIZONTAL |
957 | $string = str_replace("\200", '─', $string); |
958 | // BOX DRAWINGS LIGHT VERTICAL |
959 | $string = str_replace("\201", '│', $string); |
960 | // BOX DRAWINGS LIGHT DOWN AND RIGHT |
961 | $string = str_replace("\202", '┌', $string); |
962 | // BOX DRAWINGS LIGHT DOWN AND LEFT |
963 | $string = str_replace("\203", '┐', $string); |
964 | // BOX DRAWINGS LIGHT UP AND RIGHT |
965 | $string = str_replace("\204", '└', $string); |
966 | // BOX DRAWINGS LIGHT UP AND LEFT |
967 | $string = str_replace("\205", '┘', $string); |
968 | // BOX DRAWINGS LIGHT VERTICAL AND RIGHT |
969 | $string = str_replace("\206", '├', $string); |
970 | // BOX DRAWINGS LIGHT VERTICAL AND LEFT |
971 | $string = str_replace("\207", '┤', $string); |
972 | // BOX DRAWINGS LIGHT DOWN AND HORIZONTAL |
973 | $string = str_replace("\210", '┬', $string); |
974 | // BOX DRAWINGS LIGHT UP AND HORIZONTAL |
975 | $string = str_replace("\211", '┴', $string); |
976 | // BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL |
977 | $string = str_replace("\212", '┼', $string); |
978 | // UPPER HALF BLOCK |
979 | $string = str_replace("\213", '▀', $string); |
980 | // LOWER HALF BLOCK |
981 | $string = str_replace("\214", '▄', $string); |
982 | // FULL BLOCK |
983 | $string = str_replace("\215", '█', $string); |
984 | // LEFT HALF BLOCK |
985 | $string = str_replace("\216", '▌', $string); |
986 | // RIGHT HALF BLOCK |
987 | $string = str_replace("\217", '▐', $string); |
988 | // LIGHT SHADE |
989 | $string = str_replace("\220", '░', $string); |
990 | // MEDIUM SHADE |
991 | $string = str_replace("\221", '▒', $string); |
992 | // DARK SHADE |
993 | $string = str_replace("\222", '▓', $string); |
994 | // TOP HALF INTEGRAL |
995 | $string = str_replace("\223", '⌠', $string); |
996 | // BLACK SQUARE |
997 | $string = str_replace("\224", '■', $string); |
998 | // BULLET OPERATOR |
999 | $string = str_replace("\225", '∙', $string); |
1000 | // SQUARE ROOT |
1001 | $string = str_replace("\226", '√', $string); |
1002 | // ALMOST EQUAL TO |
1003 | $string = str_replace("\227", '≈', $string); |
1004 | // LESS THAN OR EQUAL TO |
1005 | $string = str_replace("\230", '≤', $string); |
1006 | // GREATER THAN OR EQUAL TO |
1007 | $string = str_replace("\231", '≥', $string); |
1008 | // NO-BREAK SPACE |
1009 | $string = str_replace("\232", ' ', $string); |
1010 | // BOTTOM HALF INTEGRAL |
1011 | $string = str_replace("\233", '⌡', $string); |
1012 | // DEGREE SIGN |
1013 | $string = str_replace("\234", '°', $string); |
1014 | // SUPERSCRIPT DIGIT TWO |
1015 | $string = str_replace("\235", '²', $string); |
1016 | // MIDDLE DOT |
1017 | $string = str_replace("\236", '·', $string); |
1018 | // DIVISION SIGN |
1019 | $string = str_replace("\237", '÷', $string); |
1020 | // BOX DRAWINGS DOUBLE HORIZONTAL |
1021 | $string = str_replace("\240", '═', $string); |
1022 | // BOX DRAWINGS DOUBLE VERTICAL |
1023 | $string = str_replace("\241", '║', $string); |
1024 | // BOX DRAWINGS DOWN SINGLE AND RIGHT DOUBLE |
1025 | $string = str_replace("\242", '╒', $string); |
1026 | // CYRILLIC SMALL LETTER IO |
1027 | $string = str_replace("\243", 'ё', $string); |
1028 | // CYRILLIC SMALL LETTER UKRAINIAN IE |
1029 | $string = str_replace("\244", 'є', $string); |
1030 | // BOX DRAWINGS DOUBLE DOWN AND RIGHT |
1031 | $string = str_replace("\245", '╔', $string); |
1032 | // CYRILLIC SMALL LETTER BYELORUSSIAN-UKRAINIAN I |
1033 | $string = str_replace("\246", 'і', $string); |
1034 | // CYRILLIC SMALL LETTER YI (Ukrainian) |
1035 | $string = str_replace("\247", 'ї', $string); |
1036 | // BOX DRAWINGS DOUBLE DOWN AND LEFT |
1037 | $string = str_replace("\250", '╗', $string); |
1038 | // BOX DRAWINGS UP SINGLE AND RIGHT DOUBLE |
1039 | $string = str_replace("\251", '╘', $string); |
1040 | // BOX DRAWINGS UP DOUBLE AND RIGHT SINGLE |
1041 | $string = str_replace("\252", '╙', $string); |
1042 | // BOX DRAWINGS DOUBLE UP AND RIGHT |
1043 | $string = str_replace("\253", '╚', $string); |
1044 | // BOX DRAWINGS UP SINGLE AND LEFT DOUBLE |
1045 | $string = str_replace("\254", '╛', $string); |
1046 | // CYRILLIC SMALL LETTER GHE WITH UPTURN |
1047 | $string = str_replace("\255", 'ґ', $string); |
1048 | // BOX DRAWINGS DOUBLE UP AND LEFT |
1049 | $string = str_replace("\256", '╝', $string); |
1050 | // BOX DRAWINGS VERTICAL SINGLE AND RIGHT DOUBLE |
1051 | $string = str_replace("\257", '╞', $string); |
1052 | // BOX DRAWINGS VERTICAL DOUBLE AND RIGHT SINGLE |
1053 | $string = str_replace("\260", '╟', $string); |
1054 | // BOX DRAWINGS DOUBLE VERTICAL AND RIGHT |
1055 | $string = str_replace("\261", '╠', $string); |
1056 | // BOX DRAWINGS VERTICAL SINGLE AND LEFT DOUBLE |
1057 | $string = str_replace("\262", '╡', $string); |
1058 | // CYRILLIC CAPITAL LETTER IO |
1059 | $string = str_replace("\263", 'Ё', $string); |
1060 | // CYRILLIC CAPITAL LETTER UKRAINIAN IE |
1061 | $string = str_replace("\264", 'Є', $string); |
1062 | // DOUBLE VERTICAL AND LEFT |
1063 | $string = str_replace("\265", '╣', $string); |
1064 | // CYRILLIC CAPITAL LETTER BYELORUSSIAN-UKRAINIAN I |
1065 | $string = str_replace("\266", 'І', $string); |
1066 | // CYRILLIC CAPITAL LETTER YI (Ukrainian) |
1067 | $string = str_replace("\267", 'Ї', $string); |
1068 | // BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL |
1069 | $string = str_replace("\270", '╦', $string); |
1070 | // BOX DRAWINGS UP SINGLE AND HORIZONTAL DOUBLE |
1071 | $string = str_replace("\271", '╧', $string); |
1072 | // BOX DRAWINGS UP DOUBLE AND HORIZONTAL SINGLE |
1073 | $string = str_replace("\272", '╨', $string); |
1074 | // BOX DRAWINGS DOUBLE UP AND HORIZONTAL |
1075 | $string = str_replace("\273", '╩', $string); |
1076 | // BOX DRAWINGS VERTICAL SINGLE AND HORIZONTAL DOUBLE |
1077 | $string = str_replace("\274", '╪', $string); |
1078 | // CYRILLIC CAPITAL LETTER GHE WITH UPTURN |
1079 | $string = str_replace("\275", 'Ґ', $string); |
1080 | // BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL |
1081 | $string = str_replace("\276", '╬', $string); |
1082 | // COPYRIGHT SIGN |
1083 | $string = str_replace("\277", '©', $string); |
1084 | // CYRILLIC SMALL LETTER YU |
1085 | $string = str_replace("\300", 'ю', $string); |
1086 | // CYRILLIC SMALL LETTER A |
1087 | $string = str_replace("\301", 'а', $string); |
1088 | // CYRILLIC SMALL LETTER BE |
1089 | $string = str_replace("\302", 'б', $string); |
1090 | // CYRILLIC SMALL LETTER TSE |
1091 | $string = str_replace("\303", 'ц', $string); |
1092 | // CYRILLIC SMALL LETTER DE |
1093 | $string = str_replace("\304", 'д', $string); |
1094 | // CYRILLIC SMALL LETTER IE |
1095 | $string = str_replace("\305", 'е', $string); |
1096 | // CYRILLIC SMALL LETTER EF |
1097 | $string = str_replace("\306", 'ф', $string); |
1098 | // CYRILLIC SMALL LETTER GHE |
1099 | $string = str_replace("\307", 'г', $string); |
1100 | // CYRILLIC SMALL LETTER HA |
1101 | $string = str_replace("\310", 'х', $string); |
1102 | // CYRILLIC SMALL LETTER I |
1103 | $string = str_replace("\311", 'и', $string); |
1104 | // CYRILLIC SMALL LETTER SHORT I |
1105 | $string = str_replace("\312", 'й', $string); |
1106 | // CYRILLIC SMALL LETTER KA |
1107 | $string = str_replace("\313", 'к', $string); |
1108 | // CYRILLIC SMALL LETTER EL |
1109 | $string = str_replace("\314", 'л', $string); |
1110 | // CYRILLIC SMALL LETTER EM |
1111 | $string = str_replace("\315", 'м', $string); |
1112 | // CYRILLIC SMALL LETTER EN |
1113 | $string = str_replace("\316", 'н', $string); |
1114 | // CYRILLIC SMALL LETTER O |
1115 | $string = str_replace("\317", 'о', $string); |
1116 | // CYRILLIC SMALL LETTER PE |
1117 | $string = str_replace("\320", 'п', $string); |
1118 | // CYRILLIC SMALL LETTER YA |
1119 | $string = str_replace("\321", 'я', $string); |
1120 | // CYRILLIC SMALL LETTER ER |
1121 | $string = str_replace("\322", 'р', $string); |
1122 | // CYRILLIC SMALL LETTER ES |
1123 | $string = str_replace("\323", 'с', $string); |
1124 | // CYRILLIC SMALL LETTER TE |
1125 | $string = str_replace("\324", 'т', $string); |
1126 | // CYRILLIC SMALL LETTER U |
1127 | $string = str_replace("\325", 'у', $string); |
1128 | // CYRILLIC SMALL LETTER ZHE |
1129 | $string = str_replace("\326", 'ж', $string); |
1130 | // CYRILLIC SMALL LETTER VE |
1131 | $string = str_replace("\327", 'в', $string); |
1132 | // CYRILLIC SMALL LETTER SOFT SIGN |
1133 | $string = str_replace("\330", 'ь', $string); |
1134 | // CYRILLIC SMALL LETTER YERU |
1135 | $string = str_replace("\331", 'ы', $string); |
1136 | // CYRILLIC SMALL LETTER ZE |
1137 | $string = str_replace("\332", 'з', $string); |
1138 | // CYRILLIC SMALL LETTER SHA |
1139 | $string = str_replace("\333", 'ш', $string); |
1140 | // CYRILLIC SMALL LETTER E |
1141 | $string = str_replace("\334", 'э', $string); |
1142 | // CYRILLIC SMALL LETTER SHCHA |
1143 | $string = str_replace("\335", 'щ', $string); |
1144 | // CYRILLIC SMALL LETTER CHE |
1145 | $string = str_replace("\336", 'ч', $string); |
1146 | // CYRILLIC SMALL LETTER HARD SIGN |
1147 | $string = str_replace("\337", 'ъ', $string); |
1148 | // CYRILLIC CAPITAL LETTER YU |
1149 | $string = str_replace("\340", 'Ю', $string); |
1150 | // CYRILLIC CAPITAL LETTER A |
1151 | $string = str_replace("\341", 'А', $string); |
1152 | // CYRILLIC CAPITAL LETTER BE |
1153 | $string = str_replace("\342", 'Б', $string); |
1154 | // CYRILLIC CAPITAL LETTER TSE |
1155 | $string = str_replace("\343", 'Ц', $string); |
1156 | // CYRILLIC CAPITAL LETTER DE |
1157 | $string = str_replace("\344", 'Д', $string); |
1158 | // CYRILLIC CAPITAL LETTER IE |
1159 | $string = str_replace("\345", 'Е', $string); |
1160 | // CYRILLIC CAPITAL LETTER EF |
1161 | $string = str_replace("\346", 'Ф', $string); |
1162 | // CYRILLIC CAPITAL LETTER GHE |
1163 | $string = str_replace("\347", 'Г', $string); |
1164 | // CYRILLIC CAPITAL LETTER HA |
1165 | $string = str_replace("\350", 'Х', $string); |
1166 | // CYRILLIC CAPITAL LETTER I |
1167 | $string = str_replace("\351", 'И', $string); |
1168 | // CYRILLIC CAPITAL LETTER SHORT I |
1169 | $string = str_replace("\352", 'Й', $string); |
1170 | // CYRILLIC CAPITAL LETTER KA |
1171 | $string = str_replace("\353", 'К', $string); |
1172 | // CYRILLIC CAPITAL LETTER EL |
1173 | $string = str_replace("\354", 'Л', $string); |
1174 | // CYRILLIC CAPITAL LETTER EM |
1175 | $string = str_replace("\355", 'М', $string); |
1176 | // CYRILLIC CAPITAL LETTER EN |
1177 | $string = str_replace("\356", 'Н', $string); |
1178 | // CYRILLIC CAPITAL LETTER O |
1179 | $string = str_replace("\357", 'О', $string); |
1180 | // CYRILLIC CAPITAL LETTER PE |
1181 | $string = str_replace("\360", 'П', $string); |
1182 | // CYRILLIC CAPITAL LETTER YA |
1183 | $string = str_replace("\361", 'Я', $string); |
1184 | // CYRILLIC CAPITAL LETTER ER |
1185 | $string = str_replace("\362", 'Р', $string); |
1186 | // CYRILLIC CAPITAL LETTER ES |
1187 | $string = str_replace("\363", 'С', $string); |
1188 | // CYRILLIC CAPITAL LETTER TE |
1189 | $string = str_replace("\364", 'Т', $string); |
1190 | // CYRILLIC CAPITAL LETTER U |
1191 | $string = str_replace("\365", 'У', $string); |
1192 | // CYRILLIC CAPITAL LETTER ZHE |
1193 | $string = str_replace("\366", 'Ж', $string); |
1194 | // CYRILLIC CAPITAL LETTER VE |
1195 | $string = str_replace("\367", 'В', $string); |
1196 | // CYRILLIC CAPITAL LETTER SOFT SIGN |
1197 | $string = str_replace("\370", 'Ь', $string); |
1198 | // CYRILLIC CAPITAL LETTER YERU |
1199 | $string = str_replace("\371", 'Ы', $string); |
1200 | // CYRILLIC CAPITAL LETTER ZE |
1201 | $string = str_replace("\372", 'З', $string); |
1202 | // CYRILLIC CAPITAL LETTER SHA |
1203 | $string = str_replace("\373", 'Ш', $string); |
1204 | // CYRILLIC CAPITAL LETTER E |
1205 | $string = str_replace("\374", 'Э', $string); |
1206 | // CYRILLIC CAPITAL LETTER SHCHA |
1207 | $string = str_replace("\375", 'Щ', $string); |
1208 | // CYRILLIC CAPITAL LETTER CHE |
1209 | $string = str_replace("\376", 'Ч', $string); |
1210 | // CYRILLIC CAPITAL LETTER HARD SIGN |
1211 | $string = str_replace("\377", 'Ъ', $string); |
1212 | |
1213 | return $string; |
1214 | } |
1215 | |
1216 | /* |
1217 | * windows-1251 is used to encode Bulgarian mail (Cyrrilic). |
1218 | */ |
1219 | function charset_decode_windows_1251 ($string) { |
1220 | global $default_charset; |
1221 | |
1222 | if (strtolower($default_charset) == 'windows-1251') { |
1223 | return $string; |
1224 | } |
1225 | |
1226 | /* Only do the slow convert if there are 8-bit characters */ |
1227 | if (! ereg("[\200-\377]", $string)) |
1228 | return $string; |
1229 | |
1230 | // CYRILLIC CAPITAL LETTER DJE (Serbocroatian) |
1231 | $string = str_replace("\200", 'Ђ', $string); |
1232 | // CYRILLIC CAPITAL LETTER GJE |
1233 | $string = str_replace("\201", 'Ѓ', $string); |
1234 | // SINGLE LOW-9 QUOTATION MARK |
1235 | $string = str_replace("\202", '‚', $string); |
1236 | // CYRILLIC SMALL LETTER GJE |
1237 | $string = str_replace("\203", 'ѓ', $string); |
1238 | // DOUBLE LOW-9 QUOTATION MARK |
1239 | $string = str_replace("\204", '„', $string); |
1240 | // HORIZONTAL ELLIPSIS |
1241 | $string = str_replace("\205", '…', $string); |
1242 | // DAGGER |
1243 | $string = str_replace("\206", '†', $string); |
1244 | // DOUBLE DAGGER |
1245 | $string = str_replace("\207", '‡', $string); |
1246 | // EURO SIGN |
1247 | $string = str_replace("\210", '€', $string); |
1248 | // PER MILLE SIGN |
1249 | $string = str_replace("\211", '‰', $string); |
1250 | // CYRILLIC CAPITAL LETTER LJE |
1251 | $string = str_replace("\212", 'Љ', $string); |
1252 | // SINGLE LEFT-POINTING ANGLE QUOTATION MARK |
1253 | $string = str_replace("\213", '‹', $string); |
1254 | // CYRILLIC CAPITAL LETTER NJE |
1255 | $string = str_replace("\214", 'Њ', $string); |
1256 | // CYRILLIC CAPITAL LETTER KJE |
1257 | $string = str_replace("\215", 'Ќ', $string); |
1258 | // CYRILLIC CAPITAL LETTER TSHE (Serbocroatian) |
1259 | $string = str_replace("\216", 'Ћ', $string); |
1260 | // CYRILLIC CAPITAL LETTER DZHE |
1261 | $string = str_replace("\217", 'Џ', $string); |
1262 | // CYRILLIC SMALL LETTER DJE (Serbocroatian) |
1263 | $string = str_replace("\220", 'ђ', $string); |
1264 | // LEFT SINGLE QUOTATION MARK |
1265 | $string = str_replace("\221", '‘', $string); |
1266 | // RIGHT SINGLE QUOTATION MARK |
1267 | $string = str_replace("\222", '’', $string); |
1268 | // LEFT DOUBLE QUOTATION MARK |
1269 | $string = str_replace("\223", '“', $string); |
1270 | // RIGHT DOUBLE QUOTATION MARK |
1271 | $string = str_replace("\224", '”', $string); |
1272 | // BULLET |
1273 | $string = str_replace("\225", '•', $string); |
1274 | // EN DASH |
1275 | $string = str_replace("\226", '–', $string); |
1276 | // EM DASH |
1277 | $string = str_replace("\227", '—', $string); |
1278 | // TRADE MARK SIGN |
1279 | $string = str_replace("\231", '™', $string); |
1280 | // CYRILLIC SMALL LETTER LJE |
1281 | $string = str_replace("\232", 'љ', $string); |
1282 | // SINGLE RIGHT-POINTING ANGLE QUOTATION MARK |
1283 | $string = str_replace("\233", '›', $string); |
1284 | // CYRILLIC SMALL LETTER NJE |
1285 | $string = str_replace("\234", 'њ', $string); |
1286 | // CYRILLIC SMALL LETTER KJE |
1287 | $string = str_replace("\235", 'ќ', $string); |
1288 | // CYRILLIC SMALL LETTER TSHE (Serbocroatian) |
1289 | $string = str_replace("\236", 'ћ', $string); |
1290 | // CYRILLIC SMALL LETTER DZHE |
1291 | $string = str_replace("\237", 'џ', $string); |
1292 | // NO-BREAK SPACE |
1293 | $string = str_replace("\240", ' ', $string); |
1294 | // CYRILLIC CAPITAL LETTER SHORT U (Byelorussian) |
1295 | $string = str_replace("\241", 'Ў', $string); |
1296 | // CYRILLIC SMALL LETTER SHORT U (Byelorussian) |
1297 | $string = str_replace("\242", 'ў', $string); |
1298 | // CYRILLIC CAPITAL LETTER JE |
1299 | $string = str_replace("\243", 'Ј', $string); |
1300 | // CURRENCY SIGN |
1301 | $string = str_replace("\244", '¤', $string); |
1302 | // CYRILLIC CAPITAL LETTER GHE WITH UPTURN |
1303 | $string = str_replace("\245", 'Ґ', $string); |
1304 | // BROKEN BAR |
1305 | $string = str_replace("\246", '¦', $string); |
1306 | // SECTION SIGN |
1307 | $string = str_replace("\247", '§', $string); |
1308 | // CYRILLIC CAPITAL LETTER IO |
1309 | $string = str_replace("\250", 'Ё', $string); |
1310 | // COPYRIGHT SIGN |
1311 | $string = str_replace("\251", '©', $string); |
1312 | // CYRILLIC CAPITAL LETTER UKRAINIAN IE |
1313 | $string = str_replace("\252", 'Є', $string); |
1314 | // LEFT-POINTING DOUBLE ANGLE QUOTATION MARK |
1315 | $string = str_replace("\253", '«', $string); |
1316 | // NOT SIGN |
1317 | $string = str_replace("\254", '¬', $string); |
1318 | // SOFT HYPHEN |
1319 | $string = str_replace("\255", '­', $string); |
1320 | // REGISTERED SIGN |
1321 | $string = str_replace("\256", '®', $string); |
1322 | // CYRILLIC CAPITAL LETTER YI (Ukrainian) |
1323 | $string = str_replace("\257", 'Ї', $string); |
1324 | // DEGREE SIGN |
1325 | $string = str_replace("\260", '°', $string); |
1326 | // PLUS-MINUS SIGN |
1327 | $string = str_replace("\261", '±', $string); |
1328 | // CYRILLIC CAPITAL LETTER BYELORUSSIAN-UKRAINIAN I |
1329 | $string = str_replace("\262", 'І', $string); |
1330 | // CYRILLIC SMALL LETTER BYELORUSSIAN-UKRAINIAN I |
1331 | $string = str_replace("\263", 'і', $string); |
1332 | // CYRILLIC SMALL LETTER GHE WITH UPTURN |
1333 | $string = str_replace("\264", 'ґ', $string); |
1334 | // MICRO SIGN |
1335 | $string = str_replace("\265", 'µ', $string); |
1336 | // PILCROW SIGN |
1337 | $string = str_replace("\266", '¶', $string); |
1338 | // MIDDLE DOT |
1339 | $string = str_replace("\267", '·', $string); |
1340 | // CYRILLIC SMALL LETTER IO |
1341 | $string = str_replace("\270", 'ё', $string); |
1342 | // NUMERO SIGN |
1343 | $string = str_replace("\271", '№', $string); |
1344 | // CYRILLIC SMALL LETTER UKRAINIAN IE |
1345 | $string = str_replace("\272", 'є', $string); |
1346 | // RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK |
1347 | $string = str_replace("\273", '»', $string); |
1348 | // CYRILLIC SMALL LETTER JE |
1349 | $string = str_replace("\274", 'ј', $string); |
1350 | // CYRILLIC CAPITAL LETTER DZE |
1351 | $string = str_replace("\275", 'Ѕ', $string); |
1352 | // CYRILLIC SMALL LETTER DZE |
1353 | $string = str_replace("\276", 'ѕ', $string); |
1354 | // CYRILLIC SMALL LETTER YI (Ukrainian) |
1355 | $string = str_replace("\277", 'ї', $string); |
1356 | |
1357 | // 192-255 > 1040-1103 (+848) |
1358 | $string = preg_replace("/([\300-\377])/e","'&#' . (ord('\\1')+848) . ';'",$string); |
1359 | |
1360 | return $string; |
1361 | } |
1362 | |
1363 | /* |
1364 | windows-1253 (Greek) |
1365 | */ |
1366 | function charset_decode_windows_1253 ($string) { |
1367 | global $default_charset; |
1368 | |
1369 | if (strtolower($default_charset) == 'windows-1253') |
1370 | return $string; |
1371 | |
1372 | /* Only do the slow convert if there are 8-bit characters */ |
1373 | if (! ereg("[\200-\377]", $string)) |
1374 | return $string; |
1375 | |
1376 | $string = str_replace("\200", '€', $string); |
1377 | $string = str_replace("\202", '‚', $string); |
1378 | $string = str_replace("\203", 'ƒ', $string); |
1379 | $string = str_replace("\204", '„', $string); |
1380 | $string = str_replace("\205", '…', $string); |
1381 | $string = str_replace("\206", '†', $string); |
1382 | $string = str_replace("\207", '‡', $string); |
1383 | $string = str_replace("\211", '‰', $string); |
1384 | $string = str_replace("\213", '‹', $string); |
1385 | $string = str_replace("\221", '‘', $string); |
1386 | $string = str_replace("\222", '’', $string); |
1387 | $string = str_replace("\223", '“', $string); |
1388 | $string = str_replace("\224", '”', $string); |
1389 | $string = str_replace("\225", '•', $string); |
1390 | $string = str_replace("\226", '–', $string); |
1391 | $string = str_replace("\227", '—', $string); |
1392 | $string = str_replace("\231", '™', $string); |
1393 | $string = str_replace("\233", '›', $string); |
1394 | $string = str_replace("\241", '΅', $string); |
1395 | $string = str_replace("\242", 'Ά', $string); |
1396 | $string = str_replace ("\257", '―', $string); |
1397 | $string = str_replace("\264", '΄', $string); |
1398 | $string = str_replace("\270", 'Έ', $string); |
1399 | $string = str_replace ("\271", 'Ή', $string); |
1400 | $string = str_replace ("\272", 'Ί', $string); |
1401 | $string = str_replace ("\274", 'Ό', $string); |
1402 | // cycle for 190-254 symbols |
1403 | $string = preg_replace("/([\274-\376])/e","'&#' . (ord('\\1')+720);",$string); |
1404 | |
1405 | // Rest of charset is like iso-8859-1 |
1406 | return (charset_decode_iso_8859_1($string)); |
1407 | } |
1408 | |
1409 | /* |
3ab35042 |
1410 | windows-1254 (Turks) |
c37a12f8 |
1411 | */ |
3ab35042 |
1412 | function charset_decode_windows_1254 ($string) { |
94965562 |
1413 | global $default_charset; |
c37a12f8 |
1414 | |
3ab35042 |
1415 | if (strtolower($default_charset) == 'windows-1254') |
c37a12f8 |
1416 | return $string; |
c37a12f8 |
1417 | |
1418 | /* Only do the slow convert if there are 8-bit characters */ |
1419 | if (! ereg("[\200-\377]", $string)) |
1420 | return $string; |
1421 | |
1422 | // Euro sign 128 -> 8364 |
1423 | $string = str_replace("\200", '€', $string); |
1424 | // Single low-9 quotation mark 130 -> 8218 |
1425 | $string = str_replace("\202", '‚', $string); |
3ab35042 |
1426 | // latin small letter f with hook 131 -> 402 |
1427 | $string = str_replace("\203", 'ƒ', $string); |
c37a12f8 |
1428 | // Double low-9 quotation mark 132 -> 8222 |
1429 | $string = str_replace("\204", '„', $string); |
1430 | // horizontal ellipsis 133 -> 8230 |
1431 | $string = str_replace("\205", '…', $string); |
1432 | // dagger 134 -> 8224 |
1433 | $string = str_replace("\206", '†', $string); |
1434 | // double dagger 135 -> 8225 |
1435 | $string = str_replace("\207", '‡', $string); |
3ab35042 |
1436 | // modifier letter circumflex accent 136->710 |
1437 | $string = str_replace("\210", 'ˆ', $string); |
c37a12f8 |
1438 | // per mille sign 137 -> 8240 |
1439 | $string = str_replace("\211", '‰', $string); |
3ab35042 |
1440 | // latin capital letter s with caron 138 -> 352 |
1441 | $string = str_replace("\212", 'Š', $string); |
c37a12f8 |
1442 | // single left-pointing angle quotation mark 139 -> 8249 |
1443 | $string = str_replace("\213", '‹', $string); |
3ab35042 |
1444 | // latin capital ligature oe 140 -> 338 |
1445 | $string = str_replace("\214", 'Œ', $string); |
c37a12f8 |
1446 | // left single quotation mark 145 -> 8216 |
1447 | $string = str_replace("\221", '‘', $string); |
1448 | // right single quotation mark 146 -> 8217 |
1449 | $string = str_replace("\222", '’', $string); |
1450 | // left double quotation mark 147 -> 8220 |
1451 | $string = str_replace("\223", '“', $string); |
1452 | // right double quotation mark 148 -> 8221 |
1453 | $string = str_replace("\224", '”', $string); |
1454 | // bullet 149 -> 8226 |
1455 | $string = str_replace("\225", '•', $string); |
1456 | // en dash 150 -> 8211 |
1457 | $string = str_replace("\226", '–', $string); |
1458 | // em dash 151 -> 8212 |
1459 | $string = str_replace("\227", '—', $string); |
3ab35042 |
1460 | // small tilde 152 -> 732 |
1461 | $string = str_replace("\230", '˜', $string); |
c37a12f8 |
1462 | // trade mark sign 153 -> 8482 |
1463 | $string = str_replace("\231", '™', $string); |
3ab35042 |
1464 | // latin small letter s with caron 154 -> 353 |
1465 | $string = str_replace("\232", 'š', $string); |
c37a12f8 |
1466 | // single right-pointing angle quotation mark 155 -> 8250 |
1467 | $string = str_replace("\233", '›', $string); |
3ab35042 |
1468 | // latin small ligature oe 156 -> 339 |
1469 | $string = str_replace("\234", 'œ', $string); |
1470 | // latin capital letter y with diaresis 159->376 |
1471 | $string = str_replace("\237", 'Ÿ', $string); |
1472 | // latin capital letter g with breve 208->286 |
1473 | $string = str_replace("\320", 'Ğ', $string); |
1474 | // latin capital letter i with dot above 221->304 |
1475 | $string = str_replace("\335", 'İ', $string); |
1476 | // latin capital letter s with cedilla 222->350 |
1477 | $string = str_replace("\336", 'Ş', $string); |
1478 | // latin small letter g with breve 240->287 |
1479 | $string = str_replace("\360", 'ğ', $string); |
1480 | // latin small letter dotless i 253->305 |
1481 | $string = str_replace("\375", 'ı', $string); |
1482 | // latin small letter s with cedilla 254->351 |
1483 | $string = str_replace("\376", 'ş', $string); |
1484 | |
1485 | // Rest of charset is like iso-8859-1 |
1486 | return (charset_decode_iso_8859_1($string)); |
1487 | } |
1488 | |
1489 | /* |
c48a8ca7 |
1490 | windows-1255 (Hebr) |
1491 | */ |
1492 | function charset_decode_windows_1255 ($string) { |
1493 | global $default_charset; |
1494 | |
1495 | if (strtolower($default_charset) == 'windows-1255') |
1496 | return $string; |
1497 | |
1498 | /* Only do the slow convert if there are 8-bit characters */ |
1499 | if (! ereg("[\200-\377]", $string)) |
1500 | return $string; |
1501 | |
1502 | $string = str_replace("\200", '€', $string); |
1503 | $string = str_replace("\202", '‚', $string); |
1504 | $string = str_replace("\203", 'ƒ', $string); |
1505 | $string = str_replace("\204", '„', $string); |
1506 | $string = str_replace("\205", '…', $string); |
1507 | $string = str_replace("\206", '†', $string); |
1508 | $string = str_replace("\207", '‡', $string); |
1509 | $string = str_replace("\211", '‰', $string); |
1510 | $string = str_replace("\213", '‹', $string); |
1511 | $string = str_replace("\221", '‘', $string); |
1512 | $string = str_replace("\222", '’', $string); |
1513 | $string = str_replace("\223", '“', $string); |
1514 | $string = str_replace("\224", '”', $string); |
1515 | $string = str_replace("\225", '•', $string); |
1516 | $string = str_replace("\226", '–', $string); |
1517 | $string = str_replace("\227", '—', $string); |
1518 | $string = str_replace("\231", '™', $string); |
1519 | $string = str_replace("\233", '›', $string); |
1520 | $string = str_replace("\240", ' ', $string); |
1521 | // 162-169 |
1522 | $string = preg_replace("/([\242-\251])/e","'&#' . ord('\\1') . ';'",$string); |
1523 | $string = str_replace("\252", '×', $string); |
1524 | // 171-174 |
1525 | $string = preg_replace("/([\253-\256])/e","'&#' . ord('\\1') . ';'",$string); |
1526 | $string = str_replace ("\257", '̍', $string); |
1527 | // 176-185 |
1528 | $string = preg_replace("/([\260-\271])/e","'&#' . ord('\\1') . ';'",$string); |
1529 | $string = str_replace ("\272", '÷', $string); |
1530 | // 187-190 |
1531 | $string = preg_replace("/([\273-\276])/e","'&#' . ord('\\1') . ';'",$string); |
1532 | $string = str_replace ("\337", '‗', $string); |
1533 | // 224-250 1488-1514 (+1264) |
1534 | $string = preg_replace("/([\340-\372])/e","'&#' . (ord('\\1')+1264) . ';'",$string); |
1535 | |
1536 | return ($string); |
1537 | } |
1538 | |
1539 | /* |
1540 | windows-1256 (Arab) |
1541 | */ |
1542 | function charset_decode_windows_1256 ($string) { |
1543 | global $default_charset; |
1544 | |
1545 | if (strtolower($default_charset) == 'windows-1256') |
1546 | return $string; |
1547 | |
1548 | /* Only do the slow convert if there are 8-bit characters */ |
1549 | if (! ereg("[\200-\377]", $string)) |
1550 | return $string; |
1551 | |
1552 | $string = str_replace("\200", '،', $string); |
1553 | $string = str_replace("\202", '‚', $string); |
1554 | $string = str_replace("\204", '„', $string); |
1555 | $string = str_replace("\205", '…', $string); |
1556 | $string = str_replace("\206", '†', $string); |
1557 | $string = str_replace("\207", '‡', $string); |
1558 | $string = str_replace("\211", '‰', $string); |
1559 | $string = str_replace("\213", '‹', $string); |
1560 | $string = str_replace("\221", '‘', $string); |
1561 | $string = str_replace("\222", '’', $string); |
1562 | $string = str_replace("\223", '“', $string); |
1563 | $string = str_replace("\224", '”', $string); |
1564 | $string = str_replace("\225", '•', $string); |
1565 | $string = str_replace("\226", '–', $string); |
1566 | $string = str_replace("\227", '—', $string); |
1567 | $string = str_replace("\230", '؜', $string); |
1568 | $string = str_replace("\231", '™', $string); |
1569 | $string = str_replace("\232", '؟', $string); |
1570 | $string = str_replace("\233", '›', $string); |
1571 | $string = str_replace("\234", 'ء', $string); |
1572 | $string = str_replace("\235", 'آ', $string); |
1573 | $string = str_replace("\236", 'أ', $string); |
1574 | $string = str_replace("\237", 'Ÿ', $string); |
1575 | $string = str_replace("\241", 'ؤ', $string); |
1576 | $string = str_replace("\242", 'إ', $string); |
1577 | $string = str_replace("\245", 'ئ', $string); |
1578 | $string = str_replace ("\250", 'ا', $string); |
1579 | $string = str_replace ("\252", 'ب', $string); |
1580 | $string = str_replace ("\262", 'ة', $string); |
1581 | $string = str_replace ("\263", 'ت', $string); |
1582 | $string = str_replace ("\264", 'ث', $string); |
1583 | $string = str_replace ("\270", 'ج', $string); |
1584 | $string = str_replace ("\272", 'ح', $string); |
1585 | $string = str_replace ("\274", 'خ', $string); |
1586 | $string = str_replace ("\275", 'د', $string); |
1587 | $string = str_replace ("\276", 'ذ', $string); |
1588 | $string = str_replace ("\277", 'ر', $string); |
1589 | $string = str_replace ("\301", 'ز', $string); |
1590 | $string = str_replace ("\304", 'س', $string); |
1591 | $string = str_replace ("\305", 'ش', $string); |
1592 | $string = str_replace ("\306", 'ص', $string); |
1593 | $string = str_replace ("\314", 'ض', $string); |
1594 | $string = str_replace ("\315", 'ط', $string); |
1595 | $string = str_replace ("\320", 'ظ', $string); |
1596 | $string = str_replace ("\321", 'ع', $string); |
1597 | $string = str_replace ("\322", 'غ', $string); |
1598 | $string = str_replace ("\323", 'ـ', $string); |
1599 | $string = str_replace ("\325", 'ف', $string); |
1600 | $string = str_replace ("\326", 'ق', $string); |
1601 | $string = str_replace ("\330", 'ك', $string); |
1602 | $string = str_replace ("\332", 'گ', $string); |
1603 | $string = str_replace ("\335", 'ل', $string); |
1604 | $string = str_replace ("\336", 'م', $string); |
1605 | $string = str_replace ("\337", 'ن', $string); |
1606 | $string = str_replace ("\341", 'ه', $string); |
1607 | $string = str_replace ("\344", 'و', $string); |
1608 | $string = str_replace ("\345", 'ى', $string); |
1609 | $string = str_replace ("\346", 'ي', $string); |
1610 | $string = str_replace ("\354", 'ً', $string); |
1611 | $string = str_replace ("\355", 'ٌ', $string); |
1612 | $string = str_replace ("\360", 'ٍ', $string); |
1613 | $string = str_replace ("\361", 'َ', $string); |
1614 | $string = str_replace ("\362", 'ُ', $string); |
1615 | $string = str_replace ("\363", 'ِ', $string); |
1616 | $string = str_replace ("\365", 'ّ', $string); |
1617 | $string = str_replace ("\366", 'ْ', $string); |
1618 | |
1619 | // Rest of charset is like iso-8859-1 |
1620 | return (charset_decode_iso_8859_1($string)); |
1621 | } |
1622 | |
1623 | /* |
3ab35042 |
1624 | windows-1257 (BaltRim) |
1625 | */ |
1626 | function charset_decode_windows_1257 ($string) { |
94965562 |
1627 | global $default_charset; |
3ab35042 |
1628 | |
1629 | if (strtolower($default_charset) == 'windows-1257') |
1630 | return $string; |
3ab35042 |
1631 | |
1632 | /* Only do the slow convert if there are 8-bit characters */ |
1633 | if (! ereg("[\200-\377]", $string)) |
1634 | return $string; |
1635 | |
1636 | $string = str_replace("\200", '€', $string); |
1637 | $string = str_replace("\202", '‚', $string); |
1638 | $string = str_replace("\204", '„', $string); |
1639 | $string = str_replace("\205", '…', $string); |
1640 | $string = str_replace("\206", '†', $string); |
1641 | $string = str_replace("\207", '‡', $string); |
1642 | $string = str_replace("\211", '‰', $string); |
1643 | $string = str_replace("\213", '‹', $string); |
1644 | $string = str_replace("\215", '¨', $string); |
1645 | $string = str_replace("\216", 'ˇ', $string); |
1646 | $string = str_replace("\217", '¸', $string); |
1647 | $string = str_replace("\221", '‘', $string); |
1648 | $string = str_replace("\222", '’', $string); |
1649 | $string = str_replace("\223", '“', $string); |
1650 | $string = str_replace("\224", '”', $string); |
1651 | $string = str_replace("\225", '•', $string); |
1652 | $string = str_replace("\226", '–', $string); |
1653 | $string = str_replace("\227", '—', $string); |
1654 | $string = str_replace("\231", '™', $string); |
1655 | $string = str_replace("\233", '›', $string); |
c37a12f8 |
1656 | $string = str_replace("\235", '¯', $string); |
c37a12f8 |
1657 | $string = str_replace("\236", '˛', $string); |
c37a12f8 |
1658 | $string = str_replace ("\250", 'Ø', $string); |
c37a12f8 |
1659 | $string = str_replace ("\252", 'Ŗ', $string); |
c37a12f8 |
1660 | $string = str_replace ("\257", 'Æ', $string); |
c37a12f8 |
1661 | $string = str_replace ("\270", 'ø', $string); |
c37a12f8 |
1662 | $string = str_replace ("\272", 'ŗ', $string); |
c37a12f8 |
1663 | $string = str_replace ("\277", 'æ', $string); |
c37a12f8 |
1664 | $string = str_replace ("\300", 'Ą', $string); |
c37a12f8 |
1665 | $string = str_replace ("\301", 'Į', $string); |
c37a12f8 |
1666 | $string = str_replace ("\302", 'Ā', $string); |
c37a12f8 |
1667 | $string = str_replace ("\303", 'Ć', $string); |
c37a12f8 |
1668 | $string = str_replace ("\306", 'Ę', $string); |
c37a12f8 |
1669 | $string = str_replace ("\307", 'Ē', $string); |
c37a12f8 |
1670 | $string = str_replace ("\310", 'Č', $string); |
c37a12f8 |
1671 | $string = str_replace ("\312", 'Ź', $string); |
c37a12f8 |
1672 | $string = str_replace ("\313", 'Ė', $string); |
c37a12f8 |
1673 | $string = str_replace ("\314", 'Ģ', $string); |
c37a12f8 |
1674 | $string = str_replace ("\315", 'Ķ', $string); |
c37a12f8 |
1675 | $string = str_replace ("\316", 'Ī', $string); |
c37a12f8 |
1676 | $string = str_replace ("\317", 'Ļ', $string); |
c37a12f8 |
1677 | $string = str_replace ("\320", 'Š', $string); |
c37a12f8 |
1678 | $string = str_replace ("\321", 'Ń', $string); |
c37a12f8 |
1679 | $string = str_replace ("\322", 'Ņ', $string); |
c37a12f8 |
1680 | $string = str_replace ("\324", 'Ō', $string); |
c37a12f8 |
1681 | $string = str_replace ("\330", 'Ų', $string); |
c37a12f8 |
1682 | $string = str_replace ("\331", 'Ł', $string); |
c37a12f8 |
1683 | $string = str_replace ("\332", 'Ŕ', $string); |
c37a12f8 |
1684 | $string = str_replace ("\333", 'Ū', $string); |
c37a12f8 |
1685 | $string = str_replace ("\335", 'Ż', $string); |
c37a12f8 |
1686 | $string = str_replace ("\336", 'Ž', $string); |
c37a12f8 |
1687 | $string = str_replace ("\340", 'ą', $string); |
c37a12f8 |
1688 | $string = str_replace ("\341", 'į', $string); |
c37a12f8 |
1689 | $string = str_replace ("\342", 'ā', $string); |
c37a12f8 |
1690 | $string = str_replace ("\343", 'ć', $string); |
c37a12f8 |
1691 | $string = str_replace ("\346", 'ę', $string); |
c37a12f8 |
1692 | $string = str_replace ("\347", 'ē', $string); |
c37a12f8 |
1693 | $string = str_replace ("\350", 'č', $string); |
c37a12f8 |
1694 | $string = str_replace ("\352", 'ź', $string); |
c37a12f8 |
1695 | $string = str_replace ("\353", 'ė', $string); |
c37a12f8 |
1696 | $string = str_replace ("\354", 'ģ', $string); |
c37a12f8 |
1697 | $string = str_replace ("\355", 'ķ', $string); |
c37a12f8 |
1698 | $string = str_replace ("\356", 'ī', $string); |
c37a12f8 |
1699 | $string = str_replace ("\357", 'ļ', $string); |
c37a12f8 |
1700 | $string = str_replace ("\360", 'š', $string); |
c37a12f8 |
1701 | $string = str_replace ("\361", 'ń', $string); |
c37a12f8 |
1702 | $string = str_replace ("\362", 'ņ', $string); |
c37a12f8 |
1703 | $string = str_replace ("\364", 'ō', $string); |
c37a12f8 |
1704 | $string = str_replace ("\370", 'ų', $string); |
c37a12f8 |
1705 | $string = str_replace ("\371", 'ł', $string); |
c37a12f8 |
1706 | $string = str_replace ("\372", 'ś', $string); |
c37a12f8 |
1707 | $string = str_replace ("\373", 'ū', $string); |
c37a12f8 |
1708 | $string = str_replace ("\375", 'ż', $string); |
c37a12f8 |
1709 | $string = str_replace ("\376", 'ž', $string); |
c37a12f8 |
1710 | $string = str_replace ("\377", '˙', $string); |
1711 | |
1712 | // Rest of charset is like iso-8859-1 |
1713 | return (charset_decode_iso_8859_1($string)); |
1714 | } |
1715 | |
6fbd125b |
1716 | |
a2a7852b |
1717 | /* |
1718 | * Set up the language to be output |
1719 | * if $do_search is true, then scan the browser information |
1720 | * for a possible language that we know |
1721 | */ |
1722 | function set_up_language($sm_language, $do_search = false) { |
1723 | |
1724 | static $SetupAlready = 0; |
9eb0fbd4 |
1725 | global $use_gettext, $languages, |
a2a7852b |
1726 | $squirrelmail_language, $squirrelmail_default_language, |
1727 | $sm_notAlias; |
1728 | |
1729 | if ($SetupAlready) { |
1730 | return; |
1731 | } |
a65846a7 |
1732 | |
5c920668 |
1733 | $SetupAlready = TRUE; |
961ca3d8 |
1734 | sqgetGlobalVar('HTTP_ACCEPT_LANGUAGE', $accept_lang, SQ_SERVER); |
a2a7852b |
1735 | |
961ca3d8 |
1736 | if ($do_search && ! $sm_language && isset($accept_lang)) { |
1737 | $sm_language = substr($accept_lang, 0, 2); |
a2a7852b |
1738 | } |
66d7950f |
1739 | |
a2a7852b |
1740 | if (!$sm_language && isset($squirrelmail_default_language)) { |
1741 | $squirrelmail_language = $squirrelmail_default_language; |
66d7950f |
1742 | $sm_language = $squirrelmail_default_language; |
a2a7852b |
1743 | } |
1744 | $sm_notAlias = $sm_language; |
1745 | while (isset($languages[$sm_notAlias]['ALIAS'])) { |
1746 | $sm_notAlias = $languages[$sm_notAlias]['ALIAS']; |
1747 | } |
1748 | |
88cb1b4d |
1749 | if ( isset($sm_language) && |
5c920668 |
1750 | $use_gettext && |
1751 | $sm_language != '' && |
1752 | isset($languages[$sm_notAlias]['CHARSET']) ) { |
a65846a7 |
1753 | bindtextdomain( 'squirrelmail', SM_PATH . 'locale/' ); |
88cb1b4d |
1754 | textdomain( 'squirrelmail' ); |
7928848f |
1755 | if (function_exists('bind_textdomain_codeset')) { |
1756 | bind_textdomain_codeset ("squirrelmail", $languages[$sm_notAlias]['CHARSET'] ); |
1757 | } |
88cb1b4d |
1758 | if ( !ini_get('safe_mode') && |
5c920668 |
1759 | getenv( 'LC_ALL' ) != $sm_notAlias ) { |
1760 | putenv( "LC_ALL=$sm_notAlias" ); |
1761 | putenv( "LANG=$sm_notAlias" ); |
1762 | putenv( "LANGUAGE=$sm_notAlias" ); |
a2a7852b |
1763 | } |
88cb1b4d |
1764 | setlocale(LC_ALL, $sm_notAlias); |
5c920668 |
1765 | $squirrelmail_language = $sm_notAlias; |
538f1ab7 |
1766 | if ($squirrelmail_language == 'ja_JP' && function_exists('mb_detect_encoding') ) { |
b05c8961 |
1767 | header ('Content-Type: text/html; charset=EUC-JP'); |
1768 | if (!function_exists('mb_internal_encoding')) { |
e842b215 |
1769 | echo _("You need to have php4 installed with the multibyte string function enabled (using configure option --enable-mbstring)."); |
1770 | } |
1771 | if (function_exists('mb_language')) { |
1772 | mb_language('Japanese'); |
b05c8961 |
1773 | } |
1774 | mb_internal_encoding('EUC-JP'); |
1775 | mb_http_output('pass'); |
1776 | } else { |
5c920668 |
1777 | header( 'Content-Type: text/html; charset=' . $languages[$sm_notAlias]['CHARSET'] ); |
a2a7852b |
1778 | } |
1779 | } |
b05c8961 |
1780 | } |
a2a7852b |
1781 | |
1782 | function set_my_charset(){ |
1783 | |
1784 | /* |
1785 | * There can be a $default_charset setting in the |
1786 | * config.php file, but the user may have a different language |
1787 | * selected for a user interface. This function checks the |
1788 | * language selected by the user and tags the outgoing messages |
1789 | * with the appropriate charset corresponding to the language |
1790 | * selection. This is "more right" (tm), than just stamping the |
1791 | * message blindly with the system-wide $default_charset. |
1792 | */ |
94965562 |
1793 | global $data_dir, $username, $default_charset, $languages, $squirrelmail_default_language; |
88cb1b4d |
1794 | |
a2a7852b |
1795 | $my_language = getPref($data_dir, $username, 'language'); |
5c920668 |
1796 | if (!$my_language) { |
94965562 |
1797 | $my_language = $squirrelmail_default_language ; |
5c920668 |
1798 | } |
a2a7852b |
1799 | while (isset($languages[$my_language]['ALIAS'])) { |
f7e8861e |
1800 | $my_language = $languages[$my_language]['ALIAS']; |
a2a7852b |
1801 | } |
5c920668 |
1802 | $my_charset = $languages[$my_language]['CHARSET']; |
a2a7852b |
1803 | if ($my_charset) { |
1804 | $default_charset = $my_charset; |
1805 | } |
1806 | } |
1807 | |
a2a7852b |
1808 | /* ------------------------------ main --------------------------- */ |
1809 | |
5c920668 |
1810 | global $squirrelmail_language, $languages, $use_gettext; |
1811 | |
a2a7852b |
1812 | if (! isset($squirrelmail_language)) { |
1813 | $squirrelmail_language = ''; |
1814 | } |
1815 | |
1816 | /* This array specifies the available languages. */ |
5c920668 |
1817 | |
1818 | // The glibc locale is ca_ES. |
1819 | |
1820 | $languages['ca_ES']['NAME'] = 'Catalan'; |
1821 | $languages['ca_ES']['CHARSET'] = 'iso-8859-1'; |
1822 | $languages['ca']['ALIAS'] = 'ca_ES'; |
1823 | |
a2a7852b |
1824 | $languages['cs_CZ']['NAME'] = 'Czech'; |
1825 | $languages['cs_CZ']['CHARSET'] = 'iso-8859-2'; |
1826 | $languages['cs']['ALIAS'] = 'cs_CZ'; |
a2a7852b |
1827 | |
5c920668 |
1828 | // Danish locale is da_DK. |
1829 | |
1830 | $languages['da_DK']['NAME'] = 'Danish'; |
1831 | $languages['da_DK']['CHARSET'] = 'iso-8859-1'; |
1832 | $languages['da']['ALIAS'] = 'da_DK'; |
1833 | |
1834 | $languages['de_DE']['NAME'] = 'Deutsch'; |
1835 | $languages['de_DE']['CHARSET'] = 'iso-8859-1'; |
1836 | $languages['de']['ALIAS'] = 'de_DE'; |
a2a7852b |
1837 | |
5c920668 |
1838 | // There is no en_EN! There is en_US, en_BR, en_AU, and so forth, |
1839 | // but who cares about !US, right? Right? :) |
a2a7852b |
1840 | |
3ab35042 |
1841 | $languages['el_GR']['NAME'] = 'Greek'; |
1842 | $languages['el_GR']['CHARSET'] = 'iso-8859-7'; |
1843 | $languages['el']['ALIAS'] = 'el_GR'; |
1844 | |
5c920668 |
1845 | $languages['en_US']['NAME'] = 'English'; |
1846 | $languages['en_US']['CHARSET'] = 'iso-8859-1'; |
1847 | $languages['en']['ALIAS'] = 'en_US'; |
a2a7852b |
1848 | |
5c920668 |
1849 | $languages['es_ES']['NAME'] = 'Spanish'; |
1850 | $languages['es_ES']['CHARSET'] = 'iso-8859-1'; |
1851 | $languages['es']['ALIAS'] = 'es_ES'; |
a2a7852b |
1852 | |
5c920668 |
1853 | $languages['et_EE']['NAME'] = 'Estonian'; |
1854 | $languages['et_EE']['CHARSET'] = 'iso-8859-15'; |
1855 | $languages['et']['ALIAS'] = 'et_EE'; |
a2a7852b |
1856 | |
1ad5ab3a |
1857 | $languages['fo_FO']['NAME'] = 'Faroese'; |
1858 | $languages['fo_FO']['CHARSET'] = 'iso-8859-1'; |
1859 | $languages['fo']['ALIAS'] = 'fo_FO'; |
1860 | |
5c920668 |
1861 | $languages['fi_FI']['NAME'] = 'Finnish'; |
1862 | $languages['fi_FI']['CHARSET'] = 'iso-8859-1'; |
1863 | $languages['fi']['ALIAS'] = 'fi_FI'; |
a2a7852b |
1864 | |
5c920668 |
1865 | $languages['fr_FR']['NAME'] = 'French'; |
1866 | $languages['fr_FR']['CHARSET'] = 'iso-8859-1'; |
1867 | $languages['fr']['ALIAS'] = 'fr_FR'; |
a2a7852b |
1868 | |
5c920668 |
1869 | $languages['hr_HR']['NAME'] = 'Croatian'; |
1870 | $languages['hr_HR']['CHARSET'] = 'iso-8859-2'; |
1871 | $languages['hr']['ALIAS'] = 'hr_HR'; |
a2a7852b |
1872 | |
5c920668 |
1873 | $languages['hu_HU']['NAME'] = 'Hungarian'; |
1874 | $languages['hu_HU']['CHARSET'] = 'iso-8859-2'; |
1875 | $languages['hu']['ALIAS'] = 'hu_HU'; |
a2a7852b |
1876 | |
d90198d0 |
1877 | $languages['id_ID']['NAME'] = 'Bahasa Indonesia'; |
5c920668 |
1878 | $languages['id_ID']['CHARSET'] = 'iso-8859-1'; |
1879 | $languages['id']['ALIAS'] = 'id_ID'; |
a2a7852b |
1880 | |
5c920668 |
1881 | $languages['is_IS']['NAME'] = 'Icelandic'; |
1882 | $languages['is_IS']['CHARSET'] = 'iso-8859-1'; |
1883 | $languages['is']['ALIAS'] = 'is_IS'; |
a2a7852b |
1884 | |
5c920668 |
1885 | $languages['it_IT']['NAME'] = 'Italian'; |
1886 | $languages['it_IT']['CHARSET'] = 'iso-8859-1'; |
1887 | $languages['it']['ALIAS'] = 'it_IT'; |
a2a7852b |
1888 | |
b05c8961 |
1889 | $languages['ja_JP']['NAME'] = 'Japanese'; |
1890 | $languages['ja_JP']['CHARSET'] = 'iso-2022-jp'; |
6fbd125b |
1891 | $languages['ja_JP']['XTRA_CODE'] = 'japanese_charset_xtra'; |
b05c8961 |
1892 | $languages['ja']['ALIAS'] = 'ja_JP'; |
1893 | |
5c920668 |
1894 | $languages['ko_KR']['NAME'] = 'Korean'; |
1895 | $languages['ko_KR']['CHARSET'] = 'euc-KR'; |
1d33e35e |
1896 | $languages['ko_KR']['XTRA_CODE'] = 'korean_charset_xtra'; |
5c920668 |
1897 | $languages['ko']['ALIAS'] = 'ko_KR'; |
a2a7852b |
1898 | |
5c920668 |
1899 | $languages['nl_NL']['NAME'] = 'Dutch'; |
1900 | $languages['nl_NL']['CHARSET'] = 'iso-8859-1'; |
1901 | $languages['nl']['ALIAS'] = 'nl_NL'; |
a2a7852b |
1902 | |
5c920668 |
1903 | $languages['no_NO']['NAME'] = 'Norwegian (Bokmål)'; |
1904 | $languages['no_NO']['CHARSET'] = 'iso-8859-1'; |
1905 | $languages['no']['ALIAS'] = 'no_NO'; |
b8b4ac4a |
1906 | $languages['nn_NO']['NAME'] = 'Norwegian (Nynorsk)'; |
1907 | $languages['nn_NO']['CHARSET'] = 'iso-8859-1'; |
a2a7852b |
1908 | |
5c920668 |
1909 | $languages['pl_PL']['NAME'] = 'Polish'; |
1910 | $languages['pl_PL']['CHARSET'] = 'iso-8859-2'; |
1911 | $languages['pl']['ALIAS'] = 'pl_PL'; |
a2a7852b |
1912 | |
5c920668 |
1913 | $languages['pt_PT']['NAME'] = 'Portuguese (Portugal)'; |
1914 | $languages['pt_PT']['CHARSET'] = 'iso-8859-1'; |
a2a7852b |
1915 | $languages['pt_BR']['NAME'] = 'Portuguese (Brazil)'; |
1916 | $languages['pt_BR']['CHARSET'] = 'iso-8859-1'; |
5c920668 |
1917 | $languages['pt']['ALIAS'] = 'pt_PT'; |
a2a7852b |
1918 | |
5c920668 |
1919 | $languages['ru_RU']['NAME'] = 'Russian'; |
1920 | $languages['ru_RU']['CHARSET'] = 'koi8-r'; |
1921 | $languages['ru']['ALIAS'] = 'ru_RU'; |
a2a7852b |
1922 | |
dbec0d67 |
1923 | $languages['sr_YU']['NAME'] = 'Serbian'; |
1924 | $languages['sr_YU']['CHARSET'] = 'iso-8859-2'; |
1925 | $languages['sr']['ALIAS'] = 'sr_YU'; |
a2a7852b |
1926 | |
5c920668 |
1927 | $languages['sv_SE']['NAME'] = 'Swedish'; |
1928 | $languages['sv_SE']['CHARSET'] = 'iso-8859-1'; |
1929 | $languages['sv']['ALIAS'] = 'sv_SE'; |
a2a7852b |
1930 | |
5c920668 |
1931 | $languages['tr_TR']['NAME'] = 'Turkish'; |
1932 | $languages['tr_TR']['CHARSET'] = 'iso-8859-9'; |
1933 | $languages['tr']['ALIAS'] = 'tr_TR'; |
a2a7852b |
1934 | |
b62c1863 |
1935 | $languages['zh_TW']['NAME'] = 'Chinese Trad'; |
5c920668 |
1936 | $languages['zh_TW']['CHARSET'] = 'big5'; |
1937 | $languages['tw']['ALIAS'] = 'zh_TW'; |
a2a7852b |
1938 | |
b62c1863 |
1939 | $languages['zh_CN']['NAME'] = 'Chinese Simp'; |
1940 | $languages['zh_CN']['CHARSET'] = 'gb2312'; |
1941 | $languages['cn']['ALIAS'] = 'zh_CN'; |
8ba79a3b |
1942 | |
a2a7852b |
1943 | $languages['sk_SK']['NAME'] = 'Slovak'; |
1944 | $languages['sk_SK']['CHARSET'] = 'iso-8859-2'; |
1945 | $languages['sk']['ALIAS'] = 'sk_SK'; |
1946 | |
5c920668 |
1947 | $languages['ro_RO']['NAME'] = 'Romanian'; |
1948 | $languages['ro_RO']['CHARSET'] = 'iso-8859-2'; |
1949 | $languages['ro']['ALIAS'] = 'ro_RO'; |
a2a7852b |
1950 | |
5c920668 |
1951 | $languages['th_TH']['NAME'] = 'Thai'; |
1952 | $languages['th_TH']['CHARSET'] = 'tis-620'; |
1953 | $languages['th']['ALIAS'] = 'th_TH'; |
a2a7852b |
1954 | |
5c920668 |
1955 | $languages['lt_LT']['NAME'] = 'Lithuanian'; |
923229f2 |
1956 | $languages['lt_LT']['CHARSET'] = 'windows-1257'; |
5c920668 |
1957 | $languages['lt']['ALIAS'] = 'lt_LT'; |
a2a7852b |
1958 | |
5c920668 |
1959 | $languages['sl_SI']['NAME'] = 'Slovenian'; |
1960 | $languages['sl_SI']['CHARSET'] = 'iso-8859-2'; |
1961 | $languages['sl']['ALIAS'] = 'sl_SI'; |
a2a7852b |
1962 | |
5c920668 |
1963 | $languages['bg_BG']['NAME'] = 'Bulgarian'; |
1964 | $languages['bg_BG']['CHARSET'] = 'windows-1251'; |
1965 | $languages['bg']['ALIAS'] = 'bg_BG'; |
a2a7852b |
1966 | |
93ea3e70 |
1967 | $languages['uk_UA']['NAME'] = 'Ukrainian'; |
1968 | $languages['uk_UA']['CHARSET'] = 'koi8-u'; |
1969 | $languages['uk']['ALIAS'] = 'uk_UA'; |
1970 | |
969a0af6 |
1971 | $languages['cy_GB']['NAME'] = 'Welsh'; |
1972 | $languages['cy_GB']['CHARSET'] = 'iso-8859-1'; |
1973 | $languages['cy']['ALIAS'] = 'cy_GB'; |
b7617386 |
1974 | |
d90198d0 |
1975 | $languages['vi_VN']['NAME'] = 'Vietnamese'; |
1976 | $languages['vi_VN']['CHARSET'] = 'utf-8'; |
1977 | $languages['vi']['ALIAS'] = 'vi_VN'; |
b7617386 |
1978 | |
d3b57948 |
1979 | // Right to left languages |
1980 | |
7e3f5be8 |
1981 | $languages['ar']['NAME'] = 'Arabic'; |
1982 | $languages['ar']['CHARSET'] = 'windows-1256'; |
1983 | $languages['ar']['DIR'] = 'rtl'; |
1984 | |
ace72c6a |
1985 | $languages['he_IL']['NAME'] = 'Hebrew'; |
1986 | $languages['he_IL']['CHARSET'] = 'windows-1255'; |
1987 | $languages['he_IL']['DIR'] = 'rtl'; |
1988 | $languages['he']['ALIAS'] = 'he_IL'; |
d3b57948 |
1989 | |
5c920668 |
1990 | /* Detect whether gettext is installed. */ |
a2a7852b |
1991 | $gettext_flags = 0; |
1992 | if (function_exists('_')) { |
1993 | $gettext_flags += 1; |
1994 | } |
1995 | if (function_exists('bindtextdomain')) { |
1996 | $gettext_flags += 2; |
1997 | } |
1998 | if (function_exists('textdomain')) { |
1999 | $gettext_flags += 4; |
2000 | } |
2001 | |
5c920668 |
2002 | /* If gettext is fully loaded, cool */ |
a2a7852b |
2003 | if ($gettext_flags == 7) { |
2004 | $use_gettext = true; |
2005 | } |
5c920668 |
2006 | /* If we can fake gettext, try that */ |
a2a7852b |
2007 | elseif ($gettext_flags == 0) { |
2008 | $use_gettext = true; |
e7ab8c9d |
2009 | include_once(SM_PATH . 'functions/gettext.php'); |
a2a7852b |
2010 | } else { |
5c920668 |
2011 | /* Uh-ho. A weird install */ |
a2a7852b |
2012 | if (! $gettext_flags & 1) { |
2013 | function _($str) { |
2014 | return $str; |
2015 | } |
2016 | } |
2017 | if (! $gettext_flags & 2) { |
2018 | function bindtextdomain() { |
2019 | return; |
2020 | } |
2021 | } |
2022 | if (! $gettext_flags & 4) { |
2023 | function textdomain() { |
2024 | return; |
2025 | } |
2026 | } |
2027 | } |
2028 | |
3ab35042 |
2029 | function charset_decode_utf8 ($string) { |
2030 | /* |
2031 | Every decoded character consists of n bytes. First byte is octal |
2032 | 300-375, other bytes - always octals 200-277. |
2033 | |
2034 | \a\b characters are decoded to html code octdec(a-300)*64 + octdec(b-200) |
2035 | \a\b\c characters are decoded to html code octdec(a-340)*64*64 + octdec(b-200)*64 + octdec(c-200) |
2036 | |
2037 | decoding cycle is unfinished. please test and report problems to tokul@users.sourceforge.net |
2038 | */ |
2039 | global $default_charset, $languages, $sm_notAlias; |
2040 | |
2041 | if (strtolower($default_charset) == 'utf-8') |
2042 | return $string; |
2043 | if (strtolower($languages[$sm_notAlias]['CHARSET']) == 'utf-8') |
2044 | return $string; |
2045 | |
2046 | /* Only do the slow convert if there are 8-bit characters */ |
2047 | if (! ereg("[\200-\377]", $string)) |
2048 | return $string; |
2049 | |
2050 | // decode three byte unicode characters |
2051 | $string = preg_replace("/([\340-\357])([\200-\277])([\200-\277])/e", |
2052 | "'&#'.((ord('\\1')-224)*4096+(ord('\\2')-128)*64+(ord('\\3')-128)).';'", |
2053 | $string); |
2054 | |
2055 | // decode two byte unicode characters |
2056 | $string = preg_replace("/([\300-\337])([\200-\277])/e", |
2057 | "'&#'.((ord('\\1')-192)*64+(ord('\\2')-128)).';'", |
2058 | $string); |
2059 | |
2060 | return $string; |
2061 | } |
1d33e35e |
2062 | |
2063 | /* |
2064 | * Japanese charset extra function |
2065 | * |
2066 | */ |
2067 | function japanese_charset_xtra() { |
2068 | $ret = func_get_arg(1); /* default return value */ |
2069 | if (function_exists('mb_detect_encoding')) { |
2070 | switch (func_get_arg(0)) { /* action */ |
2071 | case 'decode': |
e842b215 |
2072 | $detect_encoding = @mb_detect_encoding($ret); |
1d33e35e |
2073 | if ($detect_encoding == 'JIS' || |
2074 | $detect_encoding == 'EUC-JP' || |
e842b215 |
2075 | $detect_encoding == 'SJIS' || |
2076 | $detect_encoding == 'UTF-8') { |
1d33e35e |
2077 | |
e842b215 |
2078 | $ret = mb_convert_kana(mb_convert_encoding($ret, 'EUC-JP', 'AUTO'), "KV"); |
1d33e35e |
2079 | } |
2080 | break; |
2081 | case 'encode': |
e842b215 |
2082 | $detect_encoding = @mb_detect_encoding($ret); |
1d33e35e |
2083 | if ($detect_encoding == 'JIS' || |
2084 | $detect_encoding == 'EUC-JP' || |
e842b215 |
2085 | $detect_encoding == 'SJIS' || |
2086 | $detect_encoding == 'UTF-8') { |
1d33e35e |
2087 | |
e842b215 |
2088 | $ret = mb_convert_encoding(mb_convert_kana($ret, "KV"), 'JIS', 'AUTO'); |
1d33e35e |
2089 | } |
2090 | break; |
2091 | case 'strimwidth': |
2092 | $width = func_get_arg(2); |
2093 | $ret = mb_strimwidth($ret, 0, $width, '...'); |
2094 | break; |
2095 | case 'encodeheader': |
8ba05cbe |
2096 | $result = ''; |
2097 | if (strlen($ret) > 0) { |
2098 | $tmpstr = mb_substr($ret, 0, 1); |
2099 | $prevcsize = strlen($tmpstr); |
2100 | for ($i = 1; $i < mb_strlen($ret); $i++) { |
2101 | $tmp = mb_substr($ret, $i, 1); |
2102 | if (strlen($tmp) == $prevcsize) { |
2103 | $tmpstr .= $tmp; |
2104 | } else { |
2105 | if ($prevcsize == 1) { |
2106 | $result .= $tmpstr; |
2107 | } else { |
e842b215 |
2108 | $result .= str_replace(' ', '', |
2109 | mb_encode_mimeheader($tmpstr,'iso-2022-jp','B','')); |
8ba05cbe |
2110 | } |
2111 | $tmpstr = $tmp; |
2112 | $prevcsize = strlen($tmp); |
2113 | } |
2114 | } |
2115 | if (strlen($tmpstr)) { |
2116 | if (strlen(mb_substr($tmpstr, 0, 1)) == 1) |
2117 | $result .= $tmpstr; |
2118 | else |
e842b215 |
2119 | $result .= str_replace(' ', '', |
2120 | mb_encode_mimeheader($tmpstr,'iso-2022-jp','B','')); |
8ba05cbe |
2121 | } |
2122 | } |
2123 | $ret = $result; |
1d33e35e |
2124 | break; |
2125 | case 'decodeheader': |
2126 | $ret = str_replace("\t", "", $ret); |
2127 | if (eregi('=\\?([^?]+)\\?(q|b)\\?([^?]+)\\?=', $ret)) |
e842b215 |
2128 | $ret = @mb_decode_mimeheader($ret); |
2129 | $ret = @mb_convert_encoding($ret, 'EUC-JP', 'AUTO'); |
1d33e35e |
2130 | break; |
2131 | case 'downloadfilename': |
2132 | $useragent = func_get_arg(2); |
2133 | if (strstr($useragent, 'Windows') !== false || |
2134 | strstr($useragent, 'Mac_') !== false) { |
2135 | $ret = mb_convert_encoding($ret, 'SJIS', 'AUTO'); |
2136 | } else { |
2137 | $ret = mb_convert_encoding($ret, 'EUC-JP', 'AUTO'); |
2138 | } |
2139 | break; |
e842b215 |
2140 | case 'wordwrap': |
2141 | $no_begin = "\x21\x25\x29\x2c\x2e\x3a\x3b\x3f\x5d\x7d\xa1\xf1\xa1\xeb\xa1" . |
2142 | "\xc7\xa1\xc9\xa2\xf3\xa1\xec\xa1\xed\xa1\xee\xa1\xa2\xa1\xa3\xa1\xb9" . |
2143 | "\xa1\xd3\xa1\xd5\xa1\xd7\xa1\xd9\xa1\xdb\xa1\xcd\xa4\xa1\xa4\xa3\xa4" . |
2144 | "\xa5\xa4\xa7\xa4\xa9\xa4\xc3\xa4\xe3\xa4\xe5\xa4\xe7\xa4\xee\xa1\xab" . |
2145 | "\xa1\xac\xa1\xb5\xa1\xb6\xa5\xa1\xa5\xa3\xa5\xa5\xa5\xa7\xa5\xa9\xa5" . |
2146 | "\xc3\xa5\xe3\xa5\xe5\xa5\xe7\xa5\xee\xa5\xf5\xa5\xf6\xa1\xa6\xa1\xbc" . |
2147 | "\xa1\xb3\xa1\xb4\xa1\xaa\xa1\xf3\xa1\xcb\xa1\xa4\xa1\xa5\xa1\xa7\xa1" . |
2148 | "\xa8\xa1\xa9\xa1\xcf\xa1\xd1"; |
2149 | $no_end = "\x5c\x24\x28\x5b\x7b\xa1\xf2\x5c\xa1\xc6\xa1\xc8\xa1\xd2\xa1" . |
2150 | "\xd4\xa1\xd6\xa1\xd8\xa1\xda\xa1\xcc\xa1\xf0\xa1\xca\xa1\xce\xa1\xd0\xa1\xef"; |
2151 | $wrap = func_get_arg(2); |
2152 | |
2153 | if (strlen($ret) >= $wrap && |
2154 | substr($ret, 0, 1) != '>' && |
2155 | strpos($ret, 'http://') === FALSE && |
2156 | strpos($ret, 'https://') === FALSE && |
2157 | strpos($ret, 'ftp://') === FALSE) { |
2158 | |
2159 | $ret = mb_convert_kana($ret, "KV"); |
2160 | |
2161 | $line_new = ''; |
2162 | $ptr = 0; |
2163 | |
2164 | while ($ptr < strlen($ret) - 1) { |
2165 | $l = mb_strcut($ret, $ptr, $wrap); |
2166 | $ptr += strlen($l); |
2167 | $tmp = $l; |
2168 | |
2169 | $l = mb_strcut($ret, $ptr, 2); |
2170 | while (strlen($l) != 0 && mb_strpos($no_begin, $l) !== FALSE ) { |
2171 | $tmp .= $l; |
2172 | $ptr += strlen($l); |
2173 | $l = mb_strcut($ret, $ptr, 1); |
2174 | } |
2175 | $line_new .= $tmp; |
2176 | if ($ptr < strlen($ret) - 1) |
2177 | $line_new .= "\n"; |
2178 | } |
2179 | $ret = $line_new; |
2180 | } |
2181 | break; |
2182 | case 'utf7-imap_encode': |
2183 | $ret = mb_convert_encoding($ret, 'UTF7-IMAP', 'EUC-JP'); |
2184 | break; |
2185 | case 'utf7-imap_decode': |
2186 | $ret = mb_convert_encoding($ret, 'EUC-JP', 'UTF7-IMAP'); |
2187 | break; |
1d33e35e |
2188 | } |
2189 | } |
2190 | return $ret; |
2191 | } |
2192 | |
2193 | |
2194 | /* |
2195 | * Korean charset extra function |
2196 | * Hangul(Korean Character) Attached File Name Fix. |
2197 | */ |
2198 | function korean_charset_xtra() { |
2199 | |
2200 | $ret = func_get_arg(1); /* default return value */ |
2201 | if (func_get_arg(0) == 'downloadfilename') { /* action */ |
2202 | $ret = str_replace("\x0D\x0A", '', $ret); /* Hanmail's CR/LF Clear */ |
2203 | for ($i=0;$i<strlen($ret);$i++) { |
2204 | if ($ret[$i] >= "\xA1" && $ret[$i] <= "\xFE") { /* 0xA1 - 0XFE are Valid */ |
2205 | $i++; |
2206 | continue; |
2207 | } else if (($ret[$i] >= 'a' && $ret[$i] <= 'z') || /* From Original ereg_replace in download.php */ |
2208 | ($ret[$i] >= 'A' && $ret[$i] <= 'Z') || |
2209 | ($ret[$i] == '.') || ($ret[$i] == '-')) { |
2210 | continue; |
2211 | } else { |
2212 | $ret[$i] = '_'; |
2213 | } |
2214 | } |
2215 | |
2216 | } |
2217 | |
2218 | return $ret; |
2219 | } |
2220 | |
e842b215 |
2221 | ?> |