adding address book block
[squirrelmail.git] / functions / decode / cp866.php
CommitLineData
e9a71964 1<?php
d6c32258 2/**
e9a71964 3 * decode/cp866.php
e9a71964 4 *
82d304a0 5 * Copyright (c) 2003-2004 The SquirrelMail Project Team
e9a71964 6 * Licensed under the GNU GPL. For full terms see the file COPYING.
7 *
8 * This file contains cp866 decoding function that is needed to read
9 * cp866 encoded mails in non-cp866 locale.
10 *
11 * Original data taken from:
12 * ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/
13
14 Name: cp866_DOSCyrillicRussian to Unicode table
15 Unicode version: 2.0
16 Table version: 2.00
17 Table format: Format A
18 Date: 04/24/96
19 Authors: Lori Brownell <loribr@microsoft.com>
20 K.D. Chang <a-kchang@microsoft.com>
21 The entries are in cp866_DOSCyrillicRussian order
31841a9e 22 *
23 * @version $Id$
d6c32258 24 * @package squirrelmail
25 * @subpackage decode
e9a71964 26*/
27
d6c32258 28/**
29 * Decode a cp866-encoded string
30 * @param string $string Encoded string
31 * @return string $string Decoded string
32 */
e9a71964 33function charset_decode_cp866 ($string) {
34 global $default_charset;
35
36 if (strtolower($default_charset) == 'ibm866')
37 return $string;
38
e53c9681 39 // don't do decoding when there are no 8bit symbols
40 if (! sq_is8bit($string,'ibm866'))
e9a71964 41 return $string;
42
43 $cp866 = array(
44 "\x80" => '&#1040;',
45 "\x81" => '&#1041;',
46 "\x82" => '&#1042;',
47 "\x83" => '&#1043;',
48 "\x84" => '&#1044;',
49 "\x85" => '&#1045;',
50 "\x86" => '&#1046;',
51 "\x87" => '&#1047;',
52 "\x88" => '&#1048;',
53 "\x89" => '&#1049;',
54 "\x8a" => '&#1050;',
55 "\x8b" => '&#1051;',
56 "\x8c" => '&#1052;',
57 "\x8d" => '&#1053;',
58 "\x8e" => '&#1054;',
59 "\x8f" => '&#1055;',
60 "\x90" => '&#1056;',
61 "\x91" => '&#1057;',
62 "\x92" => '&#1058;',
63 "\x93" => '&#1059;',
64 "\x94" => '&#1060;',
65 "\x95" => '&#1061;',
66 "\x96" => '&#1062;',
67 "\x97" => '&#1063;',
68 "\x98" => '&#1064;',
69 "\x99" => '&#1065;',
70 "\x9a" => '&#1066;',
71 "\x9b" => '&#1067;',
72 "\x9c" => '&#1068;',
73 "\x9d" => '&#1069;',
74 "\x9e" => '&#1070;',
75 "\x9f" => '&#1071;',
76 "\xa0" => '&#1072;',
77 "\xa1" => '&#1073;',
78 "\xa2" => '&#1074;',
79 "\xa3" => '&#1075;',
80 "\xa4" => '&#1076;',
81 "\xa5" => '&#1077;',
82 "\xa6" => '&#1078;',
83 "\xa7" => '&#1079;',
84 "\xa8" => '&#1080;',
85 "\xa9" => '&#1081;',
86 "\xaa" => '&#1082;',
87 "\xab" => '&#1083;',
88 "\xac" => '&#1084;',
89 "\xad" => '&#1085;',
90 "\xae" => '&#1086;',
91 "\xaf" => '&#1087;',
92 "\xb0" => '&#9617;',
93 "\xb1" => '&#9618;',
94 "\xb2" => '&#9619;',
95 "\xb3" => '&#9474;',
96 "\xb4" => '&#9508;',
97 "\xb5" => '&#9569;',
98 "\xb6" => '&#9570;',
99 "\xb7" => '&#9558;',
100 "\xb8" => '&#9557;',
101 "\xb9" => '&#9571;',
102 "\xba" => '&#9553;',
103 "\xbb" => '&#9559;',
104 "\xbc" => '&#9565;',
105 "\xbd" => '&#9564;',
106 "\xbe" => '&#9563;',
107 "\xbf" => '&#9488;',
108 "\xc0" => '&#9492;',
109 "\xc1" => '&#9524;',
110 "\xc2" => '&#9516;',
111 "\xc3" => '&#9500;',
112 "\xc4" => '&#9472;',
113 "\xc5" => '&#9532;',
114 "\xc6" => '&#9566;',
115 "\xc7" => '&#9567;',
116 "\xc8" => '&#9562;',
117 "\xc9" => '&#9556;',
118 "\xca" => '&#9577;',
119 "\xcb" => '&#9574;',
120 "\xcc" => '&#9568;',
121 "\xcd" => '&#9552;',
122 "\xce" => '&#9580;',
123 "\xcf" => '&#9575;',
124 "\xd0" => '&#9576;',
125 "\xd1" => '&#9572;',
126 "\xd2" => '&#9573;',
127 "\xd3" => '&#9561;',
128 "\xd4" => '&#9560;',
129 "\xd5" => '&#9554;',
130 "\xd6" => '&#9555;',
131 "\xd7" => '&#9579;',
132 "\xd8" => '&#9578;',
133 "\xd9" => '&#9496;',
134 "\xda" => '&#9484;',
135 "\xdb" => '&#9608;',
136 "\xdc" => '&#9604;',
137 "\xdd" => '&#9612;',
138 "\xde" => '&#9616;',
139 "\xdf" => '&#9600;',
140 "\xe0" => '&#1088;',
141 "\xe1" => '&#1089;',
142 "\xe2" => '&#1090;',
143 "\xe3" => '&#1091;',
144 "\xe4" => '&#1092;',
145 "\xe5" => '&#1093;',
146 "\xe6" => '&#1094;',
147 "\xe7" => '&#1095;',
148 "\xe8" => '&#1096;',
149 "\xe9" => '&#1097;',
150 "\xea" => '&#1098;',
151 "\xeb" => '&#1099;',
152 "\xec" => '&#1100;',
153 "\xed" => '&#1101;',
154 "\xee" => '&#1102;',
155 "\xef" => '&#1103;',
156 "\xf0" => '&#1025;',
157 "\xf1" => '&#1105;',
158 "\xf2" => '&#1028;',
159 "\xf3" => '&#1108;',
160 "\xf4" => '&#1031;',
161 "\xf5" => '&#1111;',
162 "\xf6" => '&#1038;',
163 "\xf7" => '&#1118;',
164 "\xf8" => '&#176;',
165 "\xf9" => '&#8729;',
166 "\xfa" => '&#183;',
167 "\xfb" => '&#8730;',
168 "\xfc" => '&#8470;',
169 "\xfd" => '&#164;',
170 "\xfe" => '&#9632;',
171 "\xff" => '&#160;'
172 );
173
174 $string = str_replace(array_keys($cp866), array_values($cp866), $string);
175
176 return $string;
177}