211d912f |
1 | <?php |
2 | /* |
3 | * decode/cp1256.php |
4 | * $Id$ |
5 | * |
6 | * Copyright (c) 2003 The SquirrelMail Project Team |
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 |
21 | * |
22 | */ |
23 | |
cb104e1d |
24 | function charset_decode_cp1256 ($string) { |
211d912f |
25 | global $default_charset; |
26 | |
cb104e1d |
27 | if (strtolower($default_charset) == 'windows-1256') |
211d912f |
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 | |
cb104e1d |
35 | $cp1256 = array( |
36 | "\x80" => '€', |
37 | "\x81" => 'پ', |
38 | "\x82" => '‚', |
39 | "\x83" => 'ƒ', |
40 | "\x84" => '„', |
41 | "\x85" => '…', |
42 | "\x86" => '†', |
43 | "\x87" => '‡', |
44 | "\x88" => 'ˆ', |
45 | "\x89" => '‰', |
46 | "\x8A" => 'ٹ', |
47 | "\x8B" => '‹', |
48 | "\x8C" => 'Œ', |
49 | "\x8D" => 'چ', |
50 | "\x8E" => 'ژ', |
51 | "\x8F" => 'ڈ', |
52 | "\x90" => 'گ', |
53 | "\x91" => '‘', |
54 | "\x92" => '’', |
55 | "\x93" => '“', |
56 | "\x94" => '”', |
57 | "\x95" => '•', |
58 | "\x96" => '–', |
59 | "\x97" => '—', |
60 | "\x98" => 'ک', |
61 | "\x99" => '™', |
62 | "\x9A" => 'ڑ', |
63 | "\x9B" => '›', |
64 | "\x9C" => 'œ', |
65 | "\x9D" => '‌', |
66 | "\x9E" => '‍', |
67 | "\x9F" => 'ں', |
68 | "\xA0" => ' ', |
69 | "\xA1" => '،', |
70 | "\xA2" => '¢', |
71 | "\xA3" => '£', |
72 | "\xA4" => '¤', |
73 | "\xA5" => '¥', |
74 | "\xA6" => '¦', |
75 | "\xA7" => '§', |
76 | "\xA8" => '¨', |
77 | "\xA9" => '©', |
78 | "\xAA" => 'ھ', |
79 | "\xAB" => '«', |
80 | "\xAC" => '¬', |
81 | "\xAD" => '­', |
82 | "\xAE" => '®', |
83 | "\xAF" => '¯', |
84 | "\xB0" => '°', |
85 | "\xB1" => '±', |
86 | "\xB2" => '²', |
87 | "\xB3" => '³', |
88 | "\xB4" => '´', |
89 | "\xB5" => 'µ', |
90 | "\xB6" => '¶', |
91 | "\xB7" => '·', |
92 | "\xB8" => '¸', |
93 | "\xB9" => '¹', |
94 | "\xBA" => '؛', |
95 | "\xBB" => '»', |
96 | "\xBC" => '¼', |
97 | "\xBD" => '½', |
98 | "\xBE" => '¾', |
99 | "\xBF" => '؟', |
100 | "\xC0" => 'ہ', |
101 | "\xC1" => 'ء', |
102 | "\xC2" => 'آ', |
103 | "\xC3" => 'أ', |
104 | "\xC4" => 'ؤ', |
105 | "\xC5" => 'إ', |
106 | "\xC6" => 'ئ', |
107 | "\xC7" => 'ا', |
108 | "\xC8" => 'ب', |
109 | "\xC9" => 'ة', |
110 | "\xCA" => 'ت', |
111 | "\xCB" => 'ث', |
112 | "\xCC" => 'ج', |
113 | "\xCD" => 'ح', |
114 | "\xCE" => 'خ', |
115 | "\xCF" => 'د', |
116 | "\xD0" => 'ذ', |
117 | "\xD1" => 'ر', |
118 | "\xD2" => 'ز', |
119 | "\xD3" => 'س', |
120 | "\xD4" => 'ش', |
121 | "\xD5" => 'ص', |
122 | "\xD6" => 'ض', |
123 | "\xD7" => '×', |
124 | "\xD8" => 'ط', |
125 | "\xD9" => 'ظ', |
126 | "\xDA" => 'ع', |
127 | "\xDB" => 'غ', |
128 | "\xDC" => 'ـ', |
129 | "\xDD" => 'ف', |
130 | "\xDE" => 'ق', |
131 | "\xDF" => 'ك', |
132 | "\xE0" => 'à', |
133 | "\xE1" => 'ل', |
134 | "\xE2" => 'â', |
135 | "\xE3" => 'م', |
136 | "\xE4" => 'ن', |
137 | "\xE5" => 'ه', |
138 | "\xE6" => 'و', |
139 | "\xE7" => 'ç', |
140 | "\xE8" => 'è', |
141 | "\xE9" => 'é', |
142 | "\xEA" => 'ê', |
143 | "\xEB" => 'ë', |
144 | "\xEC" => 'ى', |
145 | "\xED" => 'ي', |
146 | "\xEE" => 'î', |
147 | "\xEF" => 'ï', |
148 | "\xF0" => 'ً', |
149 | "\xF1" => 'ٌ', |
150 | "\xF2" => 'ٍ', |
151 | "\xF3" => 'َ', |
152 | "\xF4" => 'ô', |
153 | "\xF5" => 'ُ', |
154 | "\xF6" => 'ِ', |
155 | "\xF7" => '÷', |
156 | "\xF8" => 'ّ', |
157 | "\xF9" => 'ù', |
158 | "\xFA" => 'ْ', |
159 | "\xFB" => 'û', |
160 | "\xFC" => 'ü', |
161 | "\xFD" => '‎', |
162 | "\xFE" => '‏', |
163 | "\xFF" => 'ے' |
164 | ); |
211d912f |
165 | |
cb104e1d |
166 | $string = str_replace(array_keys($cp1256), array_values($cp1256), $string); |
167 | |
168 | return $string; |
169 | } |
170 | |
171 | ?> |