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