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