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