d672fcab |
1 | <?php |
2 | /* |
3 | * decode/iso8859-16.php |
4 | * $Id$ |
5 | * |
6 | * Copyright (c) 1999-2003 The SquirrelMail Project Team |
7 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
8 | * |
9 | * This file contains iso-8859-16 decoding function that is needed to read |
10 | * iso-8859-16 encoded mails in non-iso-8859-16 locale. |
11 | * |
12 | * Original data taken from: |
13 | * ftp://ftp.unicode.org/Public/MAPPINGS/ISO8859/8859-16.TXT |
14 | * |
15 | * Name: ISO/IEC 8859-16:2001 to Unicode |
16 | * Unicode version: 3.0 |
17 | * Table version: 1.0 |
18 | * Table format: Format A |
19 | * Date: 2001 July 26 |
20 | * Authors: Markus Kuhn <mkuhn@acm.org> |
21 | * |
22 | * Original copyright: |
23 | * Copyright (c) 1999 Unicode, Inc. All Rights reserved. |
24 | * |
25 | * This file is provided as-is by Unicode, Inc. (The Unicode Consortium). |
26 | * No claims are made as to fitness for any particular purpose. No |
27 | * warranties of any kind are expressed or implied. The recipient |
28 | * agrees to determine applicability of information provided. If this |
29 | * file has been provided on optical media by Unicode, Inc., the sole |
30 | * remedy for any claim will be exchange of defective media within 90 |
31 | * days of receipt. |
32 | * |
33 | * Unicode, Inc. hereby grants the right to freely use the information |
34 | * supplied in this file in the creation of products supporting the |
35 | * Unicode Standard, and to make copies of this file in any form for |
36 | * internal or external distribution as long as this notice remains |
37 | * attached. |
38 | * |
39 | */ |
40 | function charset_decode_iso8859_16 ($string) { |
41 | global $default_charset; |
42 | |
43 | if (strtolower($default_charset) == 'iso-8859-16') |
44 | return $string; |
45 | |
46 | /* Only do the slow convert if there are 8-bit characters */ |
47 | /* there is no 0x80-0x9F letters in ISO8859-* */ |
48 | if ( ! ereg("[\241-\377]", $string) ) |
49 | return $string; |
50 | |
51 | $iso8869_16 = array( |
52 | "\xA0" => ' ', |
53 | "\xA1" => 'Ą', |
54 | "\xA2" => 'ą', |
55 | "\xA3" => 'Ł', |
56 | "\xA4" => '€', |
57 | "\xA5" => '„', |
58 | "\xA6" => 'Š', |
59 | "\xA7" => '§', |
60 | "\xA8" => 'š', |
61 | "\xA9" => '©', |
62 | "\xAA" => 'Ș', |
63 | "\xAB" => '«', |
64 | "\xAC" => 'Ź', |
65 | "\xAD" => '­', |
66 | "\xAE" => 'ź', |
67 | "\xAF" => 'Ż', |
68 | "\xB0" => '°', |
69 | "\xB1" => '±', |
70 | "\xB2" => 'Č', |
71 | "\xB3" => 'ł', |
72 | "\xB4" => 'Ž', |
73 | "\xB5" => '”', |
74 | "\xB6" => '¶', |
75 | "\xB7" => '·', |
76 | "\xB8" => 'ž', |
77 | "\xB9" => 'č', |
78 | "\xBA" => 'ș', |
79 | "\xBB" => '»', |
80 | "\xBC" => 'Œ', |
81 | "\xBD" => 'œ', |
82 | "\xBE" => 'Ÿ', |
83 | "\xBF" => 'ż', |
84 | "\xC0" => 'À', |
85 | "\xC1" => 'Á', |
86 | "\xC2" => 'Â', |
87 | "\xC3" => 'Ă', |
88 | "\xC4" => 'Ä', |
89 | "\xC5" => 'Ć', |
90 | "\xC6" => 'Æ', |
91 | "\xC7" => 'Ç', |
92 | "\xC8" => 'È', |
93 | "\xC9" => 'É', |
94 | "\xCA" => 'Ê', |
95 | "\xCB" => 'Ë', |
96 | "\xCC" => 'Ì', |
97 | "\xCD" => 'Í', |
98 | "\xCE" => 'Î', |
99 | "\xCF" => 'Ï', |
100 | "\xD0" => 'Đ', |
101 | "\xD1" => 'Ń', |
102 | "\xD2" => 'Ò', |
103 | "\xD3" => 'Ó', |
104 | "\xD4" => 'Ô', |
105 | "\xD5" => 'Ő', |
106 | "\xD6" => 'Ö', |
107 | "\xD7" => 'Ś', |
108 | "\xD8" => 'Ű', |
109 | "\xD9" => 'Ù', |
110 | "\xDA" => 'Ú', |
111 | "\xDB" => 'Û', |
112 | "\xDC" => 'Ü', |
113 | "\xDD" => 'Ę', |
114 | "\xDE" => 'Ț', |
115 | "\xDF" => 'ß', |
116 | "\xE0" => 'à', |
117 | "\xE1" => 'á', |
118 | "\xE2" => 'â', |
119 | "\xE3" => 'ă', |
120 | "\xE4" => 'ä', |
121 | "\xE5" => 'ć', |
122 | "\xE6" => 'æ', |
123 | "\xE7" => 'ç', |
124 | "\xE8" => 'è', |
125 | "\xE9" => 'é', |
126 | "\xEA" => 'ê', |
127 | "\xEB" => 'ë', |
128 | "\xEC" => 'ì', |
129 | "\xED" => 'í', |
130 | "\xEE" => 'î', |
131 | "\xEF" => 'ï', |
132 | "\xF0" => 'đ', |
133 | "\xF1" => 'ń', |
134 | "\xF2" => 'ò', |
135 | "\xF3" => 'ó', |
136 | "\xF4" => 'ô', |
137 | "\xF5" => 'ő', |
138 | "\xF6" => 'ö', |
139 | "\xF7" => 'ś', |
140 | "\xF8" => 'ű', |
141 | "\xF9" => 'ù', |
142 | "\xFA" => 'ú', |
143 | "\xFB" => 'û', |
144 | "\xFC" => 'ü', |
145 | "\xFD" => 'ę', |
146 | "\xFE" => 'ț', |
147 | "\xFF" => 'ÿ' |
148 | ); |
149 | |
150 | $string = str_replace(array_keys($iso8859_16), array_values($iso8859_16), $string); |
151 | |
152 | return $string; |
153 | } |
154 | |
155 | ?> |