211d912f |
1 | <?php |
d6c32258 |
2 | /** |
211d912f |
3 | * decode/cp1255.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 cp1255 decoding function that is needed to read |
9 | * cp1255 encoded mails in non-cp1255 locale. |
10 | * |
11 | * Original data taken from: |
12 | * ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1255.TXT |
13 | * |
14 | * Name: cp1255 to Unicode table |
15 | * Unicode version: 2.0 |
16 | * Table version: 2.01 |
17 | * Table format: Format A |
18 | * Date: 1/7/2000 |
19 | * Contact: cpxlate@microsoft.com |
31841a9e |
20 | * |
21 | * @version $Id$ |
d6c32258 |
22 | * @package squirrelmail |
23 | * @subpackage decode |
211d912f |
24 | */ |
25 | |
d6c32258 |
26 | /** |
27 | * Decode cp1255-encoded string |
28 | * @param string $string Encoded string |
29 | * @return string $string decoded string |
30 | */ |
211d912f |
31 | function charset_decode_cp1255 ($string) { |
32 | global $default_charset; |
33 | |
34 | if (strtolower($default_charset) == 'windows-1255') |
35 | return $string; |
36 | |
37 | /* Only do the slow convert if there are 8-bit characters */ |
38 | /* avoid using 0xA0 (\240) in ereg ranges. RH73 does not like that */ |
39 | if (! ereg("[\200-\237]", $string) and ! ereg("[\241-\377]", $string) ) |
40 | return $string; |
41 | |
42 | $cp1255 = array( |
43 | "\x80" => '€', |
44 | "\x81" => '�', |
45 | "\x82" => '‚', |
46 | "\x83" => 'ƒ', |
47 | "\x84" => '„', |
48 | "\x85" => '…', |
49 | "\x86" => '†', |
50 | "\x87" => '‡', |
51 | "\x88" => 'ˆ', |
52 | "\x89" => '‰', |
53 | "\x8A" => '�', |
54 | "\x8B" => '‹', |
55 | "\x8C" => '�', |
56 | "\x8D" => '�', |
57 | "\x8E" => '�', |
58 | "\x8F" => '�', |
59 | "\x90" => '�', |
60 | "\x91" => '‘', |
61 | "\x92" => '’', |
62 | "\x93" => '“', |
63 | "\x94" => '”', |
64 | "\x95" => '•', |
65 | "\x96" => '–', |
66 | "\x97" => '—', |
67 | "\x98" => '˜', |
68 | "\x99" => '™', |
69 | "\x9A" => '�', |
70 | "\x9B" => '›', |
71 | "\x9C" => '�', |
72 | "\x9D" => '�', |
73 | "\x9E" => '�', |
74 | "\x9F" => '�', |
75 | "\xA0" => ' ', |
76 | "\xA1" => '¡', |
77 | "\xA2" => '¢', |
78 | "\xA3" => '£', |
79 | "\xA4" => '₪', |
80 | "\xA5" => '¥', |
81 | "\xA6" => '¦', |
82 | "\xA7" => '§', |
83 | "\xA8" => '¨', |
84 | "\xA9" => '©', |
85 | "\xAA" => '×', |
86 | "\xAB" => '«', |
87 | "\xAC" => '¬', |
88 | "\xAD" => '­', |
89 | "\xAE" => '®', |
90 | "\xAF" => '¯', |
91 | "\xB0" => '°', |
92 | "\xB1" => '±', |
93 | "\xB2" => '²', |
94 | "\xB3" => '³', |
95 | "\xB4" => '´', |
96 | "\xB5" => 'µ', |
97 | "\xB6" => '¶', |
98 | "\xB7" => '·', |
99 | "\xB8" => '¸', |
100 | "\xB9" => '¹', |
101 | "\xBA" => '÷', |
102 | "\xBB" => '»', |
103 | "\xBC" => '¼', |
104 | "\xBD" => '½', |
105 | "\xBE" => '¾', |
106 | "\xBF" => '¿', |
107 | "\xC0" => 'ְ', |
108 | "\xC1" => 'ֱ', |
109 | "\xC2" => 'ֲ', |
110 | "\xC3" => 'ֳ', |
111 | "\xC4" => 'ִ', |
112 | "\xC5" => 'ֵ', |
113 | "\xC6" => 'ֶ', |
114 | "\xC7" => 'ַ', |
115 | "\xC8" => 'ָ', |
116 | "\xC9" => 'ֹ', |
117 | "\xCA" => '�', |
118 | "\xCB" => 'ֻ', |
119 | "\xCC" => 'ּ', |
120 | "\xCD" => 'ֽ', |
121 | "\xCE" => '־', |
122 | "\xCF" => 'ֿ', |
123 | "\xD0" => '׀', |
124 | "\xD1" => 'ׁ', |
125 | "\xD2" => 'ׂ', |
126 | "\xD3" => '׃', |
127 | "\xD4" => 'װ', |
128 | "\xD5" => 'ױ', |
129 | "\xD6" => 'ײ', |
130 | "\xD7" => '׳', |
131 | "\xD8" => '״', |
132 | "\xD9" => '�', |
133 | "\xDA" => '�', |
134 | "\xDB" => '�', |
135 | "\xDC" => '�', |
136 | "\xDD" => '�', |
137 | "\xDE" => '�', |
138 | "\xDF" => '�', |
139 | "\xE0" => 'א', |
140 | "\xE1" => 'ב', |
141 | "\xE2" => 'ג', |
142 | "\xE3" => 'ד', |
143 | "\xE4" => 'ה', |
144 | "\xE5" => 'ו', |
145 | "\xE6" => 'ז', |
146 | "\xE7" => 'ח', |
147 | "\xE8" => 'ט', |
148 | "\xE9" => 'י', |
149 | "\xEA" => 'ך', |
150 | "\xEB" => 'כ', |
151 | "\xEC" => 'ל', |
152 | "\xED" => 'ם', |
153 | "\xEE" => 'מ', |
154 | "\xEF" => 'ן', |
155 | "\xF0" => 'נ', |
156 | "\xF1" => 'ס', |
157 | "\xF2" => 'ע', |
158 | "\xF3" => 'ף', |
159 | "\xF4" => 'פ', |
160 | "\xF5" => 'ץ', |
161 | "\xF6" => 'צ', |
162 | "\xF7" => 'ק', |
163 | "\xF8" => 'ר', |
164 | "\xF9" => 'ש', |
165 | "\xFA" => 'ת', |
166 | "\xFB" => '�', |
167 | "\xFC" => '�', |
168 | "\xFD" => '‎', |
169 | "\xFE" => '‏', |
170 | "\xFF" => '�' |
171 | ); |
172 | |
173 | $string = str_replace(array_keys($cp1255), array_values($cp1255), $string); |
174 | |
175 | return $string; |
176 | } |
177 | |
d6c32258 |
178 | ?> |