d672fcab |
1 | <?php |
2 | /* |
3 | * decode/cp1257.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 cp1257 decoding function that is needed to read |
10 | * cp1257 encoded mails in non-cp1257 locale. |
11 | * |
12 | * Original data taken from: |
13 | * ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1257.TXT |
14 | * |
15 | * Name: cp1257 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_cp1257 ($string) { |
25 | global $default_charset; |
26 | |
27 | if (strtolower($default_charset) == 'windows-1257') |
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 | $cp1257 = array( |
36 | "\x80" => '€', |
37 | "\x82" => '‚', |
38 | "\x84" => '„', |
39 | "\x85" => '…', |
40 | "\x86" => '†', |
41 | "\x87" => '‡', |
42 | "\x89" => '‰', |
43 | "\x8B" => '‹', |
44 | "\x8D" => '¨', |
45 | "\x8E" => 'ˇ', |
46 | "\x8F" => '¸', |
47 | "\x91" => '‘', |
48 | "\x92" => '’', |
49 | "\x93" => '“', |
50 | "\x94" => '”', |
51 | "\x95" => '•', |
52 | "\x96" => '–', |
53 | "\x97" => '—', |
54 | "\x99" => '™', |
55 | "\x9B" => '›', |
56 | "\x9D" => '¯', |
57 | "\x9E" => '˛', |
58 | "\xA0" => ' ', |
59 | "\xA2" => '¢', |
60 | "\xA3" => '£', |
61 | "\xA4" => '¤', |
62 | "\xA6" => '¦', |
63 | "\xA7" => '§', |
64 | "\xA8" => 'Ø', |
65 | "\xA9" => '©', |
66 | "\xAA" => 'Ŗ', |
67 | "\xAB" => '«', |
68 | "\xAC" => '¬', |
69 | "\xAD" => '­', |
70 | "\xAE" => '®', |
71 | "\xAF" => 'Æ', |
72 | "\xB0" => '°', |
73 | "\xB1" => '±', |
74 | "\xB2" => '²', |
75 | "\xB3" => '³', |
76 | "\xB4" => '´', |
77 | "\xB5" => 'µ', |
78 | "\xB6" => '¶', |
79 | "\xB7" => '·', |
80 | "\xB8" => 'ø', |
81 | "\xB9" => '¹', |
82 | "\xBA" => 'ŗ', |
83 | "\xBB" => '»', |
84 | "\xBC" => '¼', |
85 | "\xBD" => '½', |
86 | "\xBE" => '¾', |
87 | "\xBF" => 'æ', |
88 | "\xC0" => 'Ą', |
89 | "\xC1" => 'Į', |
90 | "\xC2" => 'Ā', |
91 | "\xC3" => 'Ć', |
92 | "\xC4" => 'Ä', |
93 | "\xC5" => 'Å', |
94 | "\xC6" => 'Ę', |
95 | "\xC7" => 'Ē', |
96 | "\xC8" => 'Č', |
97 | "\xC9" => 'É', |
98 | "\xCA" => 'Ź', |
99 | "\xCB" => 'Ė', |
100 | "\xCC" => 'Ģ', |
101 | "\xCD" => 'Ķ', |
102 | "\xCE" => 'Ī', |
103 | "\xCF" => 'Ļ', |
104 | "\xD0" => 'Š', |
105 | "\xD1" => 'Ń', |
106 | "\xD2" => 'Ņ', |
107 | "\xD3" => 'Ó', |
108 | "\xD4" => 'Ō', |
109 | "\xD5" => 'Õ', |
110 | "\xD6" => 'Ö', |
111 | "\xD7" => '×', |
112 | "\xD8" => 'Ų', |
113 | "\xD9" => 'Ł', |
114 | "\xDA" => 'Ś', |
115 | "\xDB" => 'Ū', |
116 | "\xDC" => 'Ü', |
117 | "\xDD" => 'Ż', |
118 | "\xDE" => 'Ž', |
119 | "\xDF" => 'ß', |
120 | "\xE0" => 'ą', |
121 | "\xE1" => 'į', |
122 | "\xE2" => 'ā', |
123 | "\xE3" => 'ć', |
124 | "\xE4" => 'ä', |
125 | "\xE5" => 'å', |
126 | "\xE6" => 'ę', |
127 | "\xE7" => 'ē', |
128 | "\xE8" => 'č', |
129 | "\xE9" => 'é', |
130 | "\xEA" => 'ź', |
131 | "\xEB" => 'ė', |
132 | "\xEC" => 'ģ', |
133 | "\xED" => 'ķ', |
134 | "\xEE" => 'ī', |
135 | "\xEF" => 'ļ', |
136 | "\xF0" => 'š', |
137 | "\xF1" => 'ń', |
138 | "\xF2" => 'ņ', |
139 | "\xF3" => 'ó', |
140 | "\xF4" => 'ō', |
141 | "\xF5" => 'õ', |
142 | "\xF6" => 'ö', |
143 | "\xF7" => '÷', |
144 | "\xF8" => 'ų', |
145 | "\xF9" => 'ł', |
146 | "\xFA" => 'ś', |
147 | "\xFB" => 'ū', |
148 | "\xFC" => 'ü', |
149 | "\xFD" => 'ż', |
150 | "\xFE" => 'ž', |
151 | "\xFF" => '˙' |
152 | ); |
153 | |
154 | $string = str_replace(array_keys($cp1257), array_values($cp1257), $string); |
155 | |
156 | return $string; |
157 | } |
158 | |
159 | ?> |