59177427 |
1 | <?php |
1fd97780 |
2 | |
35586184 |
3 | /** |
4 | * i18n.php |
5 | * |
15e6162e |
6 | * Copyright (c) 1999-2002 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 | |
a2a7852b |
18 | /* Decodes a string to the internal encoding from the given charset */ |
19 | function charset_decode ($charset, $string) { |
6fbd125b |
20 | global $languages, $squirrelmail_language; |
a2a7852b |
21 | |
3714db45 |
22 | if (isset($languages[$squirrelmail_language]['XTRA_CODE']) && |
23 | function_exists($languages[$squirrelmail_language]['XTRA_CODE'])) { |
6fbd125b |
24 | $string = $languages[$squirrelmail_language]['XTRA_CODE']('decode', $string); |
25 | } |
b05c8961 |
26 | |
a2a7852b |
27 | /* All HTML special characters are 7 bit and can be replaced first */ |
28 | $string = htmlspecialchars ($string); |
29 | |
30 | $charset = strtolower($charset); |
31 | |
a2a7852b |
32 | if (ereg('iso-8859-([[:digit:]]+)', $charset, $res)) { |
33 | if ($res[1] == '1') { |
34 | $ret = charset_decode_iso_8859_1 ($string); |
35 | } else if ($res[1] == '2') { |
36 | $ret = charset_decode_iso_8859_2 ($string); |
9be313d5 |
37 | } else if ($res[1] == '4') { |
38 | $ret = charset_decode_iso_8859_4 ($string); |
a2a7852b |
39 | } else if ($res[1] == '7') { |
40 | $ret = charset_decode_iso_8859_7 ($string); |
9be313d5 |
41 | } else if ($res[1] == '13') { |
42 | $ret = charset_decode_iso_8859_13 ($string); |
a2a7852b |
43 | } else if ($res[1] == '15') { |
44 | $ret = charset_decode_iso_8859_15 ($string); |
45 | } else { |
46 | $ret = charset_decode_iso_8859_default ($string); |
47 | } |
48 | } else if ($charset == 'ns_4551-1') { |
49 | $ret = charset_decode_ns_4551_1 ($string); |
50 | } else if ($charset == 'koi8-r') { |
51 | $ret = charset_decode_koi8r ($string); |
52 | } else if ($charset == 'windows-1251') { |
53 | $ret = charset_decode_koi8r ($string); |
54 | } else { |
55 | $ret = $string; |
56 | } |
57 | return( $ret ); |
58 | } |
59 | |
60 | /* |
61 | iso-8859-1 is the same as Latin 1 and is normally used |
62 | in western europe. |
63 | */ |
64 | function charset_decode_iso_8859_1 ($string) { |
65 | global $default_charset; |
13e0c649 |
66 | |
a2a7852b |
67 | if (strtolower($default_charset) <> 'iso-8859-1') { |
68 | /* Only do the slow convert if there are 8-bit characters */ |
69 | if (ereg("[\200-\377]", $string)) { |
066c374f |
70 | $string = str_replace("\201", '', $string); |
71 | $string = str_replace("\202", '‚', $string); |
72 | $string = str_replace("\203", 'ƒ', $string); |
73 | $string = str_replace("\204", '„', $string); |
74 | $string = str_replace("\205", '…', $string); |
75 | $string = str_replace("\206", '†', $string); |
76 | $string = str_replace("\207", '‡', $string); |
77 | $string = str_replace("\210", 'ˆ', $string); |
78 | $string = str_replace("\211", '‰', $string); |
79 | $string = str_replace("\212", 'Š', $string); |
80 | $string = str_replace("\213", '‹', $string); |
81 | $string = str_replace("\214", 'Œ', $string); |
82 | $string = str_replace("\215", '', $string); |
83 | $string = str_replace("\216", 'Ž', $string); |
84 | $string = str_replace("\217", '', $string); |
85 | $string = str_replace("\220", '', $string); |
86 | $string = str_replace("\221", '‘', $string); |
87 | $string = str_replace("\222", '’', $string); |
88 | $string = str_replace("\223", '“', $string); |
89 | $string = str_replace("\224", '”', $string); |
90 | $string = str_replace("\225", '•', $string); |
91 | $string = str_replace("\226", '–', $string); |
92 | $string = str_replace("\227", '—', $string); |
93 | $string = str_replace("\230", '˜', $string); |
94 | $string = str_replace("\231", '™', $string); |
95 | $string = str_replace("\232", 'š', $string); |
96 | $string = str_replace("\233", '›', $string); |
97 | $string = str_replace("\234", 'œ', $string); |
98 | $string = str_replace("\235", '', $string); |
99 | $string = str_replace("\236", 'ž', $string); |
100 | $string = str_replace("\237", 'Ÿ', $string); |
101 | $string = str_replace("\240", ' ', $string); |
102 | $string = str_replace("\241", '¡', $string); |
103 | $string = str_replace("\242", '¢', $string); |
104 | $string = str_replace("\243", '£', $string); |
105 | $string = str_replace("\244", '¤', $string); |
106 | $string = str_replace("\245", '¥', $string); |
107 | $string = str_replace("\246", '¦', $string); |
108 | $string = str_replace("\247", '§', $string); |
109 | $string = str_replace("\250", '¨', $string); |
110 | $string = str_replace("\251", '©', $string); |
111 | $string = str_replace("\252", 'ª', $string); |
112 | $string = str_replace("\253", '«', $string); |
113 | $string = str_replace("\254", '¬', $string); |
114 | $string = str_replace("\255", '­', $string); |
115 | $string = str_replace("\256", '®', $string); |
116 | $string = str_replace("\257", '¯', $string); |
117 | $string = str_replace("\260", '°', $string); |
118 | $string = str_replace("\261", '±', $string); |
119 | $string = str_replace("\262", '²', $string); |
120 | $string = str_replace("\263", '³', $string); |
121 | $string = str_replace("\264", '´', $string); |
122 | $string = str_replace("\265", 'µ', $string); |
123 | $string = str_replace("\266", '¶', $string); |
124 | $string = str_replace("\267", '·', $string); |
125 | $string = str_replace("\270", '¸', $string); |
126 | $string = str_replace("\271", '¹', $string); |
127 | $string = str_replace("\272", 'º', $string); |
128 | $string = str_replace("\273", '»', $string); |
129 | $string = str_replace("\274", '¼', $string); |
130 | $string = str_replace("\275", '½', $string); |
131 | $string = str_replace("\276", '¾', $string); |
132 | $string = str_replace("\277", '¿', $string); |
133 | $string = str_replace("\300", 'À', $string); |
134 | $string = str_replace("\301", 'Á', $string); |
135 | $string = str_replace("\302", 'Â', $string); |
136 | $string = str_replace("\303", 'Ã', $string); |
137 | $string = str_replace("\304", 'Ä', $string); |
138 | $string = str_replace("\305", 'Å', $string); |
139 | $string = str_replace("\306", 'Æ', $string); |
140 | $string = str_replace("\307", 'Ç', $string); |
141 | $string = str_replace("\310", 'È', $string); |
142 | $string = str_replace("\311", 'É', $string); |
143 | $string = str_replace("\312", 'Ê', $string); |
144 | $string = str_replace("\313", 'Ë', $string); |
145 | $string = str_replace("\314", 'Ì', $string); |
146 | $string = str_replace("\315", 'Í', $string); |
147 | $string = str_replace("\316", 'Î', $string); |
148 | $string = str_replace("\317", 'Ï', $string); |
149 | $string = str_replace("\320", 'Ð', $string); |
150 | $string = str_replace("\321", 'Ñ', $string); |
151 | $string = str_replace("\322", 'Ò', $string); |
152 | $string = str_replace("\323", 'Ó', $string); |
153 | $string = str_replace("\324", 'Ô', $string); |
154 | $string = str_replace("\325", 'Õ', $string); |
155 | $string = str_replace("\326", 'Ö', $string); |
156 | $string = str_replace("\327", '×', $string); |
157 | $string = str_replace("\330", 'Ø', $string); |
158 | $string = str_replace("\331", 'Ù', $string); |
159 | $string = str_replace("\332", 'Ú', $string); |
160 | $string = str_replace("\333", 'Û', $string); |
161 | $string = str_replace("\334", 'Ü', $string); |
162 | $string = str_replace("\335", 'Ý', $string); |
163 | $string = str_replace("\336", 'Þ', $string); |
164 | $string = str_replace("\337", 'ß', $string); |
165 | $string = str_replace("\340", 'à', $string); |
166 | $string = str_replace("\341", 'á', $string); |
167 | $string = str_replace("\342", 'â', $string); |
168 | $string = str_replace("\343", 'ã', $string); |
169 | $string = str_replace("\344", 'ä', $string); |
170 | $string = str_replace("\345", 'å', $string); |
171 | $string = str_replace("\346", 'æ', $string); |
172 | $string = str_replace("\347", 'ç', $string); |
173 | $string = str_replace("\350", 'è', $string); |
174 | $string = str_replace("\351", 'é', $string); |
175 | $string = str_replace("\352", 'ê', $string); |
176 | $string = str_replace("\353", 'ë', $string); |
177 | $string = str_replace("\354", 'ì', $string); |
178 | $string = str_replace("\355", 'í', $string); |
179 | $string = str_replace("\356", 'î', $string); |
180 | $string = str_replace("\357", 'ï', $string); |
181 | $string = str_replace("\360", 'ð', $string); |
182 | $string = str_replace("\361", 'ñ', $string); |
183 | $string = str_replace("\362", 'ò', $string); |
184 | $string = str_replace("\363", 'ó', $string); |
185 | $string = str_replace("\364", 'ô', $string); |
186 | $string = str_replace("\365", 'õ', $string); |
187 | $string = str_replace("\366", 'ö', $string); |
188 | $string = str_replace("\367", '÷', $string); |
189 | $string = str_replace("\370", 'ø', $string); |
190 | $string = str_replace("\371", 'ù', $string); |
191 | $string = str_replace("\372", 'ú', $string); |
192 | $string = str_replace("\373", 'û', $string); |
193 | $string = str_replace("\374", 'ü', $string); |
194 | $string = str_replace("\375", 'ý', $string); |
195 | $string = str_replace("\376", 'þ', $string); |
196 | $string = str_replace("\377", 'ÿ', $string); |
a2a7852b |
197 | } |
198 | } |
199 | |
200 | return ($string); |
201 | } |
202 | |
203 | /* iso-8859-2 is used for some eastern European languages */ |
204 | function charset_decode_iso_8859_2 ($string) { |
205 | global $default_charset; |
206 | |
207 | if (strtolower($default_charset) == 'iso-8859-2') |
208 | return $string; |
209 | |
210 | /* Only do the slow convert if there are 8-bit characters */ |
211 | if (! ereg("[\200-\377]", $string)) |
212 | return $string; |
213 | |
214 | /* NO-BREAK SPACE */ |
215 | $string = str_replace("\240", ' ', $string); |
216 | /* LATIN CAPITAL LETTER A WITH OGONEK */ |
217 | $string = str_replace("\241", 'Ą', $string); |
218 | /* BREVE */ |
219 | $string = str_replace("\242", '˘', $string); |
220 | // LATIN CAPITAL LETTER L WITH STROKE |
221 | $string = str_replace("\243", 'Ł', $string); |
222 | // CURRENCY SIGN |
223 | $string = str_replace("\244", '¤', $string); |
224 | // LATIN CAPITAL LETTER L WITH CARON |
225 | $string = str_replace("\245", 'Ľ', $string); |
226 | // LATIN CAPITAL LETTER S WITH ACUTE |
227 | $string = str_replace("\246", 'Ś', $string); |
228 | // SECTION SIGN |
229 | $string = str_replace("\247", '§', $string); |
230 | // DIAERESIS |
231 | $string = str_replace("\250", '¨', $string); |
232 | // LATIN CAPITAL LETTER S WITH CARON |
233 | $string = str_replace("\251", 'Š', $string); |
234 | // LATIN CAPITAL LETTER S WITH CEDILLA |
235 | $string = str_replace("\252", 'Ş', $string); |
236 | // LATIN CAPITAL LETTER T WITH CARON |
237 | $string = str_replace("\253", 'Ť', $string); |
238 | // LATIN CAPITAL LETTER Z WITH ACUTE |
239 | $string = str_replace("\254", 'Ź', $string); |
240 | // SOFT HYPHEN |
241 | $string = str_replace("\255", '­', $string); |
242 | // LATIN CAPITAL LETTER Z WITH CARON |
243 | $string = str_replace("\256", 'Ž', $string); |
244 | // LATIN CAPITAL LETTER Z WITH DOT ABOVE |
245 | $string = str_replace("\257", 'Ż', $string); |
246 | // DEGREE SIGN |
247 | $string = str_replace("\260", '°', $string); |
248 | // LATIN SMALL LETTER A WITH OGONEK |
249 | $string = str_replace("\261", 'ą', $string); |
250 | // OGONEK |
251 | $string = str_replace("\262", '˛', $string); |
252 | // LATIN SMALL LETTER L WITH STROKE |
253 | $string = str_replace("\263", 'ł', $string); |
254 | // ACUTE ACCENT |
255 | $string = str_replace("\264", '´', $string); |
256 | // LATIN SMALL LETTER L WITH CARON |
257 | $string = str_replace("\265", 'ľ', $string); |
258 | // LATIN SMALL LETTER S WITH ACUTE |
259 | $string = str_replace("\266", 'ś', $string); |
260 | // CARON |
261 | $string = str_replace("\267", 'ˇ', $string); |
262 | // CEDILLA |
263 | $string = str_replace("\270", '¸', $string); |
264 | // LATIN SMALL LETTER S WITH CARON |
265 | $string = str_replace("\271", 'š', $string); |
266 | // LATIN SMALL LETTER S WITH CEDILLA |
267 | $string = str_replace("\272", 'ş', $string); |
268 | // LATIN SMALL LETTER T WITH CARON |
269 | $string = str_replace("\273", 'ť', $string); |
270 | // LATIN SMALL LETTER Z WITH ACUTE |
271 | $string = str_replace("\274", 'ź', $string); |
272 | // DOUBLE ACUTE ACCENT |
273 | $string = str_replace("\275", '˝', $string); |
274 | // LATIN SMALL LETTER Z WITH CARON |
275 | $string = str_replace("\276", 'ž', $string); |
276 | // LATIN SMALL LETTER Z WITH DOT ABOVE |
277 | $string = str_replace("\277", 'ż', $string); |
278 | // LATIN CAPITAL LETTER R WITH ACUTE |
279 | $string = str_replace("\300", 'Ŕ', $string); |
280 | // LATIN CAPITAL LETTER A WITH ACUTE |
281 | $string = str_replace("\301", 'Á', $string); |
282 | // LATIN CAPITAL LETTER A WITH CIRCUMFLEX |
283 | $string = str_replace("\302", 'Â', $string); |
284 | // LATIN CAPITAL LETTER A WITH BREVE |
285 | $string = str_replace("\303", 'Ă', $string); |
286 | // LATIN CAPITAL LETTER A WITH DIAERESIS |
287 | $string = str_replace("\304", 'Ä', $string); |
288 | // LATIN CAPITAL LETTER L WITH ACUTE |
289 | $string = str_replace("\305", 'Ĺ', $string); |
290 | // LATIN CAPITAL LETTER C WITH ACUTE |
291 | $string = str_replace("\306", 'Ć', $string); |
292 | // LATIN CAPITAL LETTER C WITH CEDILLA |
293 | $string = str_replace("\307", 'Ç', $string); |
294 | // LATIN CAPITAL LETTER C WITH CARON |
295 | $string = str_replace("\310", 'Č', $string); |
296 | // LATIN CAPITAL LETTER E WITH ACUTE |
297 | $string = str_replace("\311", 'É', $string); |
298 | // LATIN CAPITAL LETTER E WITH OGONEK |
299 | $string = str_replace("\312", 'Ę', $string); |
300 | // LATIN CAPITAL LETTER E WITH DIAERESIS |
301 | $string = str_replace("\313", 'Ë', $string); |
302 | // LATIN CAPITAL LETTER E WITH CARON |
303 | $string = str_replace("\314", 'Ě', $string); |
304 | // LATIN CAPITAL LETTER I WITH ACUTE |
305 | $string = str_replace("\315", 'Í', $string); |
306 | // LATIN CAPITAL LETTER I WITH CIRCUMFLEX |
307 | $string = str_replace("\316", 'Î', $string); |
308 | // LATIN CAPITAL LETTER D WITH CARON |
309 | $string = str_replace("\317", 'Ď', $string); |
310 | // LATIN CAPITAL LETTER D WITH STROKE |
311 | $string = str_replace("\320", 'Đ', $string); |
312 | // LATIN CAPITAL LETTER N WITH ACUTE |
313 | $string = str_replace("\321", 'Ń', $string); |
314 | // LATIN CAPITAL LETTER N WITH CARON |
315 | $string = str_replace("\322", 'Ň', $string); |
316 | // LATIN CAPITAL LETTER O WITH ACUTE |
317 | $string = str_replace("\323", 'Ó', $string); |
318 | // LATIN CAPITAL LETTER O WITH CIRCUMFLEX |
319 | $string = str_replace("\324", 'Ô', $string); |
320 | // LATIN CAPITAL LETTER O WITH DOUBLE ACUTE |
321 | $string = str_replace("\325", 'Ő', $string); |
322 | // LATIN CAPITAL LETTER O WITH DIAERESIS |
323 | $string = str_replace("\326", 'Ö', $string); |
324 | // MULTIPLICATION SIGN |
325 | $string = str_replace("\327", '×', $string); |
326 | // LATIN CAPITAL LETTER R WITH CARON |
327 | $string = str_replace("\330", 'Ř', $string); |
328 | // LATIN CAPITAL LETTER U WITH RING ABOVE |
329 | $string = str_replace("\331", 'Ů', $string); |
330 | // LATIN CAPITAL LETTER U WITH ACUTE |
331 | $string = str_replace("\332", 'Ú', $string); |
332 | // LATIN CAPITAL LETTER U WITH DOUBLE ACUTE |
333 | $string = str_replace("\333", 'Ű', $string); |
334 | // LATIN CAPITAL LETTER U WITH DIAERESIS |
335 | $string = str_replace("\334", 'Ü', $string); |
336 | // LATIN CAPITAL LETTER Y WITH ACUTE |
337 | $string = str_replace("\335", 'Ý', $string); |
338 | // LATIN CAPITAL LETTER T WITH CEDILLA |
339 | $string = str_replace("\336", 'Ţ', $string); |
340 | // LATIN SMALL LETTER SHARP S |
341 | $string = str_replace("\337", 'ß', $string); |
342 | // LATIN SMALL LETTER R WITH ACUTE |
343 | $string = str_replace("\340", 'ŕ', $string); |
344 | // LATIN SMALL LETTER A WITH ACUTE |
345 | $string = str_replace("\341", 'á', $string); |
346 | // LATIN SMALL LETTER A WITH CIRCUMFLEX |
347 | $string = str_replace("\342", 'â', $string); |
348 | // LATIN SMALL LETTER A WITH BREVE |
349 | $string = str_replace("\343", 'ă', $string); |
350 | // LATIN SMALL LETTER A WITH DIAERESIS |
351 | $string = str_replace("\344", 'ä', $string); |
352 | // LATIN SMALL LETTER L WITH ACUTE |
353 | $string = str_replace("\345", 'ĺ', $string); |
354 | // LATIN SMALL LETTER C WITH ACUTE |
355 | $string = str_replace("\346", 'ć', $string); |
356 | // LATIN SMALL LETTER C WITH CEDILLA |
357 | $string = str_replace("\347", 'ç', $string); |
358 | // LATIN SMALL LETTER C WITH CARON |
359 | $string = str_replace("\350", 'č', $string); |
360 | // LATIN SMALL LETTER E WITH ACUTE |
361 | $string = str_replace("\351", 'é', $string); |
362 | // LATIN SMALL LETTER E WITH OGONEK |
363 | $string = str_replace("\352", 'ę', $string); |
364 | // LATIN SMALL LETTER E WITH DIAERESIS |
365 | $string = str_replace("\353", 'ë', $string); |
366 | // LATIN SMALL LETTER E WITH CARON |
367 | $string = str_replace("\354", 'ě', $string); |
368 | // LATIN SMALL LETTER I WITH ACUTE |
369 | $string = str_replace("\355", 'í', $string); |
370 | // LATIN SMALL LETTER I WITH CIRCUMFLEX |
371 | $string = str_replace("\356", 'î', $string); |
372 | // LATIN SMALL LETTER D WITH CARON |
373 | $string = str_replace("\357", 'ď', $string); |
374 | // LATIN SMALL LETTER D WITH STROKE |
375 | $string = str_replace("\360", 'đ', $string); |
376 | // LATIN SMALL LETTER N WITH ACUTE |
377 | $string = str_replace("\361", 'ń', $string); |
378 | // LATIN SMALL LETTER N WITH CARON |
379 | $string = str_replace("\362", 'ň', $string); |
380 | // LATIN SMALL LETTER O WITH ACUTE |
381 | $string = str_replace("\363", 'ó', $string); |
382 | // LATIN SMALL LETTER O WITH CIRCUMFLEX |
383 | $string = str_replace("\364", 'ô', $string); |
384 | // LATIN SMALL LETTER O WITH DOUBLE ACUTE |
385 | $string = str_replace("\365", 'ő', $string); |
386 | // LATIN SMALL LETTER O WITH DIAERESIS |
387 | $string = str_replace("\366", 'ö', $string); |
388 | // DIVISION SIGN |
389 | $string = str_replace("\367", '÷', $string); |
390 | // LATIN SMALL LETTER R WITH CARON |
391 | $string = str_replace("\370", 'ř', $string); |
392 | // LATIN SMALL LETTER U WITH RING ABOVE |
393 | $string = str_replace("\371", 'ů', $string); |
394 | // LATIN SMALL LETTER U WITH ACUTE |
395 | $string = str_replace("\372", 'ú', $string); |
396 | // LATIN SMALL LETTER U WITH DOUBLE ACUTE |
397 | $string = str_replace("\373", 'ű', $string); |
398 | // LATIN SMALL LETTER U WITH DIAERESIS |
399 | $string = str_replace("\374", 'ü', $string); |
400 | // LATIN SMALL LETTER Y WITH ACUTE |
401 | $string = str_replace("\375", 'ý', $string); |
402 | // LATIN SMALL LETTER T WITH CEDILLA |
403 | $string = str_replace("\376", 'ţ', $string); |
404 | // DOT ABOVE |
405 | $string = str_replace("\377", '˙', $string); |
406 | |
407 | return $string; |
408 | } |
409 | |
9be313d5 |
410 | /* |
411 | iso-8859-4 is Baltic codeset used in some email clients |
412 | instead of iso-8859-13 in Lithuania |
413 | only Lithuanian charactes are added. |
414 | */ |
415 | |
416 | function charset_decode_iso_8859_4 ($string) { |
417 | // latin capital a with ogonek |
418 | $string = str_replace ("\241", 'Ą', $string); |
419 | // latin capital c with caron |
420 | $string = str_replace ("\310", 'Č', $string); |
421 | // latin capital e with ogonek |
422 | $string = str_replace ("\312", 'Ę', $string); |
423 | // latin capital e with dot above |
424 | $string = str_replace ("\314", 'Ė', $string); |
425 | // latin capital i with ogonek |
426 | $string = str_replace ("\307", 'Į', $string); |
427 | // latin capital s with caron |
428 | $string = str_replace ("\251", 'Š', $string); |
429 | // latin capital u with ogonek |
430 | $string = str_replace ("\331", 'Ų', $string); |
431 | // latin capital u with macron |
432 | $string = str_replace ("\336", 'Ū', $string); |
433 | // latin capital z with caron |
434 | $string = str_replace ("\256", 'Ž', $string); |
435 | // latin small a with ogonek |
436 | $string = str_replace ("\261", 'ą', $string); |
437 | // latin small c with caron |
438 | $string = str_replace ("\350", 'č', $string); |
439 | // latin small e with ogonek |
440 | $string = str_replace ("\352", 'ę', $string); |
441 | // latin small e with dot above |
442 | $string = str_replace ("\354", 'ė', $string); |
443 | // latin small i with ogonek |
444 | $string = str_replace ("\347", 'į', $string); |
445 | // latin small s with caron |
446 | $string = str_replace ("\271", 'š', $string); |
447 | // latin small u with ogonek |
448 | $string = str_replace ("\371", 'ų', $string); |
449 | // latin small u with macron |
450 | $string = str_replace ("\376", 'ū', $string); |
451 | // latin small z with caron |
452 | $string = str_replace ("\276", 'ž', $string); |
453 | |
454 | return (charset_decode_iso_8859_1($string)); |
455 | } |
456 | |
a2a7852b |
457 | /* iso-8859-7 is Greek. */ |
458 | function charset_decode_iso_8859_7 ($string) { |
459 | global $default_charset; |
460 | |
461 | if (strtolower($default_charset) == 'iso-8859-7') { |
462 | return $string; |
463 | } |
464 | |
465 | /* Only do the slow convert if there are 8-bit characters */ |
466 | if (!ereg("[\200-\377]", $string)) { |
467 | return $string; |
468 | } |
469 | |
470 | /* Some diverse characters in the beginning */ |
471 | $string = str_replace("\240", ' ', $string); |
472 | $string = str_replace("\241", '‘', $string); |
473 | $string = str_replace("\242", '’', $string); |
474 | $string = str_replace("\243", '£', $string); |
475 | $string = str_replace("\246", '¦', $string); |
476 | $string = str_replace("\247", '§', $string); |
477 | $string = str_replace("\250", '¨', $string); |
478 | $string = str_replace("\251", '©', $string); |
479 | $string = str_replace("\253", '«', $string); |
480 | $string = str_replace("\254", '¬', $string); |
481 | $string = str_replace("\255", '­', $string); |
482 | $string = str_replace("\257", '―', $string); |
483 | $string = str_replace("\260", '°', $string); |
484 | $string = str_replace("\261", '±', $string); |
485 | $string = str_replace("\262", '²', $string); |
486 | $string = str_replace("\263", '³', $string); |
487 | |
488 | /* Horizontal bar (parentheki pavla) */ |
489 | $string = str_replace ("\257", '―', $string); |
490 | |
491 | /* |
492 | * ISO-8859-7 characters from 11/04 (0xB4) to 11/06 (0xB6) |
493 | * These are Unicode 900-902 |
494 | */ |
49c17806 |
495 | $string = preg_replace("/([\264-\266])/","'&#' . (ord(\\1)+720)",$string); |
496 | |
a2a7852b |
497 | /* 11/07 (0xB7) Middle dot is the same in iso-8859-1 */ |
498 | $string = str_replace("\267", '·', $string); |
499 | |
500 | /* |
501 | * ISO-8859-7 characters from 11/08 (0xB8) to 11/10 (0xBA) |
502 | * These are Unicode 900-902 |
503 | */ |
49c17806 |
504 | $string = preg_replace("/([\270-\272])/","'&#' . (ord(\\1)+720)",$string); |
a2a7852b |
505 | |
506 | /* |
507 | * 11/11 (0xBB) Right angle quotation mark is the same as in |
508 | * iso-8859-1 |
509 | */ |
510 | $string = str_replace("\273", '»', $string); |
511 | |
512 | /* And now the rest of the charset */ |
49c17806 |
513 | $string = preg_replace("/([\274-\376])/","'&#' . (ord(\\1)+720)",$string); |
a2a7852b |
514 | |
515 | return $string; |
516 | } |
517 | |
9be313d5 |
518 | /* |
519 | iso-8859-13 codeset used in Lithuania |
520 | only Lithuanian charactes are added. |
521 | */ |
522 | |
523 | function charset_decode_iso_8859_13 ($string) { |
524 | // latin capital a with ogonek |
525 | $string = str_replace ("\300", 'Ą', $string); |
526 | // latin capital c with caron |
527 | $string = str_replace ("\310", 'Č', $string); |
528 | // latin capital e with ogonek |
529 | $string = str_replace ("\306", 'Ę', $string); |
530 | // latin capital e with dot above |
531 | $string = str_replace ("\313", 'Ė', $string); |
532 | // latin capital i with ogonek |
533 | $string = str_replace ("\301", 'Į', $string); |
534 | // latin capital s with caron |
535 | $string = str_replace ("\320", 'Š', $string); |
536 | // latin capital u with ogonek |
537 | $string = str_replace ("\330", 'Ų', $string); |
538 | // latin capital u with macron |
539 | $string = str_replace ("\333", 'Ū', $string); |
540 | // latin capital z with caron |
541 | $string = str_replace ("\336", 'Ž', $string); |
542 | // latin small a with ogonek |
543 | $string = str_replace ("\340", 'ą', $string); |
544 | // latin small c with caron |
545 | $string = str_replace ("\350", 'č', $string); |
546 | // latin small e with ogonek |
547 | $string = str_replace ("\346", 'ę', $string); |
548 | // latin small e with dot above |
549 | $string = str_replace ("\353", 'ė', $string); |
550 | // latin small i with ogonek |
551 | $string = str_replace ("\341", 'į', $string); |
552 | // latin small s with caron |
553 | $string = str_replace ("\360", 'š', $string); |
554 | // latin small u with ogonek |
555 | $string = str_replace ("\370", 'ų', $string); |
556 | // latin small u with macron |
557 | $string = str_replace ("\373", 'ū', $string); |
558 | // latin small z with caron |
559 | $string = str_replace ("\376", 'ž', $string); |
560 | |
561 | return (charset_decode_iso_8859_1($string)); |
562 | } |
563 | |
a2a7852b |
564 | /* |
565 | * iso-8859-15 is Latin 9 and has very much the same use as Latin 1 |
566 | * but has the Euro symbol and some characters needed for French. |
567 | */ |
568 | function charset_decode_iso_8859_15 ($string) { |
569 | // Euro sign |
570 | $string = str_replace ("\244", '€', $string); |
571 | // Latin capital letter S with caron |
84556805 |
572 | $string = str_replace ("\246", 'Š', $string); |
a2a7852b |
573 | // Latin small letter s with caron |
574 | $string = str_replace ("\250", 'š', $string); |
575 | // Latin capital letter Z with caron |
576 | $string = str_replace ("\264", 'Ž', $string); |
577 | // Latin small letter z with caron |
578 | $string = str_replace ("\270", 'ž', $string); |
579 | // Latin capital ligature OE |
580 | $string = str_replace ("\274", 'Œ', $string); |
581 | // Latin small ligature oe |
582 | $string = str_replace ("\275", 'œ', $string); |
583 | // Latin capital letter Y with diaeresis |
584 | $string = str_replace ("\276", 'Ÿ', $string); |
585 | |
586 | return (charset_decode_iso_8859_1($string)); |
587 | } |
588 | |
84556805 |
589 | /* ISO-8859-5 is Cyrillic */ |
a2a7852b |
590 | function charset_decode_iso_8859_5 ($string) { |
591 | // Convert to KOI8-R, then return this decoded. |
592 | $string = convert_cyr_string($string, 'i', 'k'); |
593 | return charset_decode_koi8r($string); |
594 | } |
595 | |
596 | /* Remove all 8 bit characters from all other ISO-8859 character sets */ |
597 | function charset_decode_iso_8859_default ($string) { |
598 | return (strtr($string, "\240\241\242\243\244\245\246\247". |
1fd97780 |
599 | "\250\251\252\253\254\255\256\257". |
600 | "\260\261\262\263\264\265\266\267". |
601 | "\270\271\272\273\274\275\276\277". |
602 | "\300\301\302\303\304\305\306\307". |
603 | "\310\311\312\313\314\315\316\317". |
604 | "\320\321\322\323\324\325\326\327". |
605 | "\330\331\332\333\334\335\336\337". |
606 | "\340\341\342\343\344\345\346\347". |
607 | "\350\351\352\353\354\355\356\357". |
608 | "\360\361\362\363\364\365\366\367". |
a2a7852b |
609 | "\370\371\372\373\374\375\376\377", |
1fd97780 |
610 | "????????????????????????????????????????". |
611 | "????????????????????????????????????????". |
612 | "????????????????????????????????????????". |
613 | "????????")); |
a2a7852b |
614 | |
615 | } |
616 | |
617 | /* |
618 | * This is the same as ISO-646-NO and is used by some |
619 | * Microsoft programs when sending Norwegian characters |
620 | */ |
621 | function charset_decode_ns_4551_1 ($string) { |
622 | /* |
623 | * These characters are: |
624 | * Latin capital letter AE |
625 | * Latin capital letter O with stroke |
626 | * Latin capital letter A with ring above |
627 | * and the same as small letters |
628 | */ |
629 |