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