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