211d912f |
1 | <?php |
d6c32258 |
2 | /** |
211d912f |
3 | * decode/cp1255.php |
4 | * $Id$ |
5 | * |
82d304a0 |
6 | * Copyright (c) 2003-2004 The SquirrelMail Project Team |
211d912f |
7 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
8 | * |
9 | * This file contains cp1255 decoding function that is needed to read |
10 | * cp1255 encoded mails in non-cp1255 locale. |
11 | * |
12 | * Original data taken from: |
13 | * ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1255.TXT |
14 | * |
15 | * Name: cp1255 to Unicode table |
16 | * Unicode version: 2.0 |
17 | * Table version: 2.01 |
18 | * Table format: Format A |
19 | * Date: 1/7/2000 |
20 | * Contact: cpxlate@microsoft.com |
d6c32258 |
21 | * @package squirrelmail |
22 | * @subpackage decode |
211d912f |
23 | */ |
24 | |
d6c32258 |
25 | /** |
26 | * Decode cp1255-encoded string |
27 | * @param string $string Encoded string |
28 | * @return string $string decoded string |
29 | */ |
211d912f |
30 | function charset_decode_cp1255 ($string) { |
31 | global $default_charset; |
32 | |
33 | if (strtolower($default_charset) == 'windows-1255') |
34 | return $string; |
35 | |
36 | /* Only do the slow convert if there are 8-bit characters */ |
37 | /* avoid using 0xA0 (\240) in ereg ranges. RH73 does not like that */ |
38 | if (! ereg("[\200-\237]", $string) and ! ereg("[\241-\377]", $string) ) |
39 | return $string; |
40 | |
41 | $cp1255 = array( |
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" => '�' |
170 | ); |
171 | |
172 | $string = str_replace(array_keys($cp1255), array_values($cp1255), $string); |
173 | |
174 | return $string; |
175 | } |
176 | |
d6c32258 |
177 | ?> |