d672fcab |
1 | <?php |
2 | /* |
3 | * decode/iso8859-2.php |
4 | * $Id$ |
5 | * |
0a708025 |
6 | * Copyright (c) 2003 The SquirrelMail Project Team |
d672fcab |
7 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
8 | * |
9 | * This file contains iso-8859-2 decoding function that is needed to read |
10 | * iso-8859-2 encoded mails in non-iso-8859-2 locale. |
11 | * |
12 | * Original data taken from: |
13 | * ftp://ftp.unicode.org/Public/MAPPINGS/ISO8859/8859-2.TXT |
14 | * |
15 | * Name: ISO 8859-2:1999 to Unicode |
16 | * Unicode version: 3.0 |
17 | * Table version: 1.0 |
18 | * Table format: Format A |
19 | * Date: 1999 July 27 |
20 | * Authors: Ken Whistler <kenw@sybase.com> |
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_2 ($string) { |
41 | global $default_charset; |
42 | |
43 | if (strtolower($default_charset) == 'iso-8859-2') |
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 | $iso8859_2 = 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_2), array_values($iso8859_2), $string); |
151 | |
152 | return $string; |
153 | } |
154 | |
155 | ?> |