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