211d912f |
1 | <?php |
2 | /* |
3 | * decode/cp1258.php |
4 | * $Id$ |
5 | * |
6 | * Copyright (c) 2003 The SquirrelMail Project Team |
7 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
8 | * |
9 | * This file contains cp1258 decoding function that is needed to read |
10 | * cp1258 encoded mails in non-cp1258 locale. |
11 | * |
12 | * Original data taken from: |
13 | * ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1258.TXT |
14 | * |
15 | * Name: cp1258 to Unicode table |
16 | * Unicode version: 2.0 |
17 | * Table version: 2.01 |
18 | * Table format: Format A |
19 | * Date: 04/15/98 |
20 | * Contact: cpxlate@microsoft.com |
21 | * |
22 | */ |
23 | |
24 | function charset_decode_cp1258 ($string) { |
25 | global $default_charset; |
26 | |
27 | if (strtolower($default_charset) == 'windows-1258') |
28 | return $string; |
29 | |
30 | /* Only do the slow convert if there are 8-bit characters */ |
31 | /* avoid using 0xA0 (\240) in ereg ranges. RH73 does not like that */ |
32 | if (! ereg("[\200-\237]", $string) and ! ereg("[\241-\377]", $string) ) |
33 | return $string; |
34 | |
35 | $cp1258 = array( |
36 | "\x80" => '€', |
37 | "\x81" => '�', |
38 | "\x82" => '‚', |
39 | "\x83" => 'ƒ', |
40 | "\x84" => '„', |
41 | "\x85" => '…', |
42 | "\x86" => '†', |
43 | "\x87" => '‡', |
44 | "\x88" => 'ˆ', |
45 | "\x89" => '‰', |
46 | "\x8A" => '�', |
47 | "\x8B" => '‹', |
48 | "\x8C" => 'Œ', |
49 | "\x8D" => '�', |
50 | "\x8E" => '�', |
51 | "\x8F" => '�', |
52 | "\x90" => '�', |
53 | "\x91" => '‘', |
54 | "\x92" => '’', |
55 | "\x93" => '“', |
56 | "\x94" => '”', |
57 | "\x95" => '•', |
58 | "\x96" => '–', |
59 | "\x97" => '—', |
60 | "\x98" => '˜', |
61 | "\x99" => '™', |
62 | "\x9A" => '�', |
63 | "\x9B" => '›', |
64 | "\x9C" => 'œ', |
65 | "\x9D" => '�', |
66 | "\x9E" => '�', |
67 | "\x9F" => 'Ÿ', |
68 | "\xA0" => ' ', |
69 | "\xA1" => '¡', |
70 | "\xA2" => '¢', |
71 | "\xA3" => '£', |
72 | "\xA4" => '¤', |
73 | "\xA5" => '¥', |
74 | "\xA6" => '¦', |
75 | "\xA7" => '§', |
76 | "\xA8" => '¨', |
77 | "\xA9" => '©', |
78 | "\xAA" => 'ª', |
79 | "\xAB" => '«', |
80 | "\xAC" => '¬', |
81 | "\xAD" => '­', |
82 | "\xAE" => '®', |
83 | "\xAF" => '¯', |
84 | "\xB0" => '°', |
85 | "\xB1" => '±', |
86 | "\xB2" => '²', |
87 | "\xB3" => '³', |
88 | "\xB4" => '´', |
89 | "\xB5" => 'µ', |
90 | "\xB6" => '¶', |
91 | "\xB7" => '·', |
92 | "\xB8" => '¸', |
93 | "\xB9" => '¹', |
94 | "\xBA" => 'º', |
95 | "\xBB" => '»', |
96 | "\xBC" => '¼', |
97 | "\xBD" => '½', |
98 | "\xBE" => '¾', |
99 | "\xBF" => '¿', |
100 | "\xC0" => 'À', |
101 | "\xC1" => 'Á', |
102 | "\xC2" => 'Â', |
103 | "\xC3" => 'Ă', |
104 | "\xC4" => 'Ä', |
105 | "\xC5" => 'Å', |
106 | "\xC6" => 'Æ', |
107 | "\xC7" => 'Ç', |
108 | "\xC8" => 'È', |
109 | "\xC9" => 'É', |
110 | "\xCA" => 'Ê', |
111 | "\xCB" => 'Ë', |
112 | "\xCC" => '̀', |
113 | "\xCD" => 'Í', |
114 | "\xCE" => 'Î', |
115 | "\xCF" => 'Ï', |
116 | "\xD0" => 'Đ', |
117 | "\xD1" => 'Ñ', |
118 | "\xD2" => '̉', |
119 | "\xD3" => 'Ó', |
120 | "\xD4" => 'Ô', |
121 | "\xD5" => 'Ơ', |
122 | "\xD6" => 'Ö', |
123 | "\xD7" => '×', |
124 | "\xD8" => 'Ø', |
125 | "\xD9" => 'Ù', |
126 | "\xDA" => 'Ú', |
127 | "\xDB" => 'Û', |
128 | "\xDC" => 'Ü', |
129 | "\xDD" => 'Ư', |
130 | "\xDE" => '̃', |
131 | "\xDF" => 'ß', |
132 | "\xE0" => 'à', |
133 | "\xE1" => 'á', |
134 | "\xE2" => 'â', |
135 | "\xE3" => 'ă', |
136 | "\xE4" => 'ä', |
137 | "\xE5" => 'å', |
138 | "\xE6" => 'æ', |
139 | "\xE7" => 'ç', |
140 | "\xE8" => 'è', |
141 | "\xE9" => 'é', |
142 | "\xEA" => 'ê', |
143 | "\xEB" => 'ë', |
144 | "\xEC" => '́', |
145 | "\xED" => 'í', |
146 | "\xEE" => 'î', |
147 | "\xEF" => 'ï', |
148 | "\xF0" => 'đ', |
149 | "\xF1" => 'ñ', |
150 | "\xF2" => '̣', |
151 | "\xF3" => 'ó', |
152 | "\xF4" => 'ô', |
153 | "\xF5" => 'ơ', |
154 | "\xF6" => 'ö', |
155 | "\xF7" => '÷', |
156 | "\xF8" => 'ø', |
157 | "\xF9" => 'ù', |
158 | "\xFA" => 'ú', |
159 | "\xFB" => 'û', |
160 | "\xFC" => 'ü', |
161 | "\xFD" => 'ư', |
162 | "\xFE" => '₫', |
163 | "\xFF" => 'ÿ' |
164 | ); |
165 | |
166 | $string = str_replace(array_keys($cp1258), array_values($cp1258), $string); |
167 | |
168 | return $string; |
169 | } |
170 | |
171 | ?> |