211d912f |
1 | <?php |
d6c32258 |
2 | /** |
211d912f |
3 | * decode/cp1256.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 cp1256 decoding function that is needed to read |
10 | * cp1256 encoded mails in non-cp1256 locale. |
11 | * |
12 | * Original data taken from: |
13 | * ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1256.TXT |
14 | * |
15 | * Name: cp1256 to Unicode table |
16 | * Unicode version: 2.1 |
17 | * Table version: 2.01 |
18 | * Table format: Format A |
19 | * Date: 01/5/99 |
20 | * Contact: cpxlate@microsoft.com |
d6c32258 |
21 | * @package squirrelmail |
22 | * @subpackage decode |
211d912f |
23 | */ |
24 | |
d6c32258 |
25 | /** |
26 | * decode cp1256-encoded string |
27 | * @param string $string Encoded string |
28 | * @return string $string Decoded string |
29 | */ |
cb104e1d |
30 | function charset_decode_cp1256 ($string) { |
211d912f |
31 | global $default_charset; |
32 | |
cb104e1d |
33 | if (strtolower($default_charset) == 'windows-1256') |
211d912f |
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 | |
cb104e1d |
41 | $cp1256 = 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 | ); |
211d912f |
171 | |
cb104e1d |
172 | $string = str_replace(array_keys($cp1256), array_values($cp1256), $string); |
173 | |
174 | return $string; |
175 | } |
176 | |
d6c32258 |
177 | ?> |