Phpdocumentor update - sed is your friend for these kinds of things ;)
[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 /* Only do the slow convert if there are 8-bit characters */
38 /* avoid using 0xA0 (\240) in ereg ranges. RH73 does not like that */
39 if (! ereg("[\200-\237]", $string) and ! ereg("[\241-\377]", $string) )
40 return $string;
41
42 $cp855 = array(
43 "\x80" => '&#1106;',
44 "\x81" => '&#1026;',
45 "\x82" => '&#1107;',
46 "\x83" => '&#1027;',
47 "\x84" => '&#1105;',
48 "\x85" => '&#1025;',
49 "\x86" => '&#1108;',
50 "\x87" => '&#1028;',
51 "\x88" => '&#1109;',
52 "\x89" => '&#1029;',
53 "\x8a" => '&#1110;',
54 "\x8b" => '&#1030;',
55 "\x8c" => '&#1111;',
56 "\x8d" => '&#1031;',
57 "\x8e" => '&#1112;',
58 "\x8f" => '&#1032;',
59 "\x90" => '&#1113;',
60 "\x91" => '&#1033;',
61 "\x92" => '&#1114;',
62 "\x93" => '&#1034;',
63 "\x94" => '&#1115;',
64 "\x95" => '&#1035;',
65 "\x96" => '&#1116;',
66 "\x97" => '&#1036;',
67 "\x98" => '&#1118;',
68 "\x99" => '&#1038;',
69 "\x9a" => '&#1119;',
70 "\x9b" => '&#1039;',
71 "\x9c" => '&#1102;',
72 "\x9d" => '&#1070;',
73 "\x9e" => '&#1098;',
74 "\x9f" => '&#1066;',
75 "\xa0" => '&#1072;',
76 "\xa1" => '&#1040;',
77 "\xa2" => '&#1073;',
78 "\xa3" => '&#1041;',
79 "\xa4" => '&#1094;',
80 "\xa5" => '&#1062;',
81 "\xa6" => '&#1076;',
82 "\xa7" => '&#1044;',
83 "\xa8" => '&#1077;',
84 "\xa9" => '&#1045;',
85 "\xaa" => '&#1092;',
86 "\xab" => '&#1060;',
87 "\xac" => '&#1075;',
88 "\xad" => '&#1043;',
89 "\xae" => '&#171;',
90 "\xaf" => '&#187;',
91 "\xb0" => '&#9617;',
92 "\xb1" => '&#9618;',
93 "\xb2" => '&#9619;',
94 "\xb3" => '&#9474;',
95 "\xb4" => '&#9508;',
96 "\xb5" => '&#1093;',
97 "\xb6" => '&#1061;',
98 "\xb7" => '&#1080;',
99 "\xb8" => '&#1048;',
100 "\xb9" => '&#9571;',
101 "\xba" => '&#9553;',
102 "\xbb" => '&#9559;',
103 "\xbc" => '&#9565;',
104 "\xbd" => '&#1081;',
105 "\xbe" => '&#1049;',
106 "\xbf" => '&#9488;',
107 "\xc0" => '&#9492;',
108 "\xc1" => '&#9524;',
109 "\xc2" => '&#9516;',
110 "\xc3" => '&#9500;',
111 "\xc4" => '&#9472;',
112 "\xc5" => '&#9532;',
113 "\xc6" => '&#1082;',
114 "\xc7" => '&#1050;',
115 "\xc8" => '&#9562;',
116 "\xc9" => '&#9556;',
117 "\xca" => '&#9577;',
118 "\xcb" => '&#9574;',
119 "\xcc" => '&#9568;',
120 "\xcd" => '&#9552;',
121 "\xce" => '&#9580;',
122 "\xcf" => '&#164;',
123 "\xd0" => '&#1083;',
124 "\xd1" => '&#1051;',
125 "\xd2" => '&#1084;',
126 "\xd3" => '&#1052;',
127 "\xd4" => '&#1085;',
128 "\xd5" => '&#1053;',
129 "\xd6" => '&#1086;',
130 "\xd7" => '&#1054;',
131 "\xd8" => '&#1087;',
132 "\xd9" => '&#9496;',
133 "\xda" => '&#9484;',
134 "\xdb" => '&#9608;',
135 "\xdc" => '&#9604;',
136 "\xdd" => '&#1055;',
137 "\xde" => '&#1103;',
138 "\xdf" => '&#9600;',
139 "\xe0" => '&#1071;',
140 "\xe1" => '&#1088;',
141 "\xe2" => '&#1056;',
142 "\xe3" => '&#1089;',
143 "\xe4" => '&#1057;',
144 "\xe5" => '&#1090;',
145 "\xe6" => '&#1058;',
146 "\xe7" => '&#1091;',
147 "\xe8" => '&#1059;',
148 "\xe9" => '&#1078;',
149 "\xea" => '&#1046;',
150 "\xeb" => '&#1074;',
151 "\xec" => '&#1042;',
152 "\xed" => '&#1100;',
153 "\xee" => '&#1068;',
154 "\xef" => '&#8470;',
155 "\xf0" => '&#173;',
156 "\xf1" => '&#1099;',
157 "\xf2" => '&#1067;',
158 "\xf3" => '&#1079;',
159 "\xf4" => '&#1047;',
160 "\xf5" => '&#1096;',
161 "\xf6" => '&#1064;',
162 "\xf7" => '&#1101;',
163 "\xf8" => '&#1069;',
164 "\xf9" => '&#1097;',
165 "\xfa" => '&#1065;',
166 "\xfb" => '&#1095;',
167 "\xfc" => '&#1063;',
168 "\xfd" => '&#167;',
169 "\xfe" => '&#9632;',
170 "\xff" => '&#160;'
171 );
172
173 $string = str_replace(array_keys($cp855), array_values($cp855), $string);
174
175 return $string;
176 }
177
178 ?>