copyright update
[squirrelmail.git] / functions / decode / koi8_r.php
1 <?php
2
3 /**
4 * decode/koi8-r.php
5 *
6 * This file contains koi8-r decoding function that is needed to read
7 * koi8-r encoded mails in non-koi8-r locale.
8 *
9 * Original data taken from:
10 * ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MISC/KOI8-R.TXT
11 *
12 * Name: KOI8-R (RFC1489) to Unicode
13 * Unicode version: 3.0
14 * Table version: 1.0
15 * Table format: Format A
16 * Date: 18 August 1999
17 * Authors: Helmut Richter <richter@lrz.de>
18 *
19 * Copyright (c) 1991-1999 Unicode, Inc. All Rights reserved.
20 *
21 * This file is provided as-is by Unicode, Inc. (The Unicode Consortium).
22 * No claims are made as to fitness for any particular purpose. No
23 * warranties of any kind are expressed or implied. The recipient
24 * agrees to determine applicability of information provided. If this
25 * file has been provided on optical media by Unicode, Inc., the sole
26 * remedy for any claim will be exchange of defective media within 90
27 * days of receipt.
28 *
29 * Unicode, Inc. hereby grants the right to freely use the information
30 * supplied in this file in the creation of products supporting the
31 * Unicode Standard, and to make copies of this file in any form for
32 * internal or external distribution as long as this notice remains
33 * attached.
34 *
35 * @copyright &copy; 2003-2006 The SquirrelMail Project Team
36 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
37 * @version $Id$
38 * @package squirrelmail
39 * @subpackage decode
40 */
41
42 /**
43 * Decode koi8r strings
44 * @param string $string Encoded string
45 * @return string Decoded string
46 */
47 function charset_decode_koi8_r ($string) {
48 // don't do decoding when there are no 8bit symbols
49 if (! sq_is8bit($string,'koi8-r'))
50 return $string;
51
52 $koi8r = array(
53 "\x80" => '&#9472;',
54 "\x81" => '&#9474;',
55 "\x82" => '&#9484;',
56 "\x83" => '&#9488;',
57 "\x84" => '&#9492;',
58 "\x85" => '&#9496;',
59 "\x86" => '&#9500;',
60 "\x87" => '&#9508;',
61 "\x88" => '&#9516;',
62 "\x89" => '&#9524;',
63 "\x8A" => '&#9532;',
64 "\x8B" => '&#9600;',
65 "\x8C" => '&#9604;',
66 "\x8D" => '&#9608;',
67 "\x8E" => '&#9612;',
68 "\x8F" => '&#9616;',
69 "\x90" => '&#9617;',
70 "\x91" => '&#9618;',
71 "\x92" => '&#9619;',
72 "\x93" => '&#8992;',
73 "\x94" => '&#9632;',
74 "\x95" => '&#8729;',
75 "\x96" => '&#8730;',
76 "\x97" => '&#8776;',
77 "\x98" => '&#8804;',
78 "\x99" => '&#8805;',
79 "\x9A" => '&#160;',
80 "\x9B" => '&#8993;',
81 "\x9C" => '&#176;',
82 "\x9D" => '&#178;',
83 "\x9E" => '&#183;',
84 "\x9F" => '&#247;',
85 "\xA0" => '&#9552;',
86 "\xA1" => '&#9553;',
87 "\xA2" => '&#9554;',
88 "\xA3" => '&#1105;',
89 "\xA4" => '&#9555;',
90 "\xA5" => '&#9556;',
91 "\xA6" => '&#9557;',
92 "\xA7" => '&#9558;',
93 "\xA8" => '&#9559;',
94 "\xA9" => '&#9560;',
95 "\xAA" => '&#9561;',
96 "\xAB" => '&#9562;',
97 "\xAC" => '&#9563;',
98 "\xAD" => '&#9564;',
99 "\xAE" => '&#9565;',
100 "\xAF" => '&#9566;',
101 "\xB0" => '&#9567;',
102 "\xB1" => '&#9568;',
103 "\xB2" => '&#9569;',
104 "\xB3" => '&#1025;',
105 "\xB4" => '&#9570;',
106 "\xB5" => '&#9571;',
107 "\xB6" => '&#9572;',
108 "\xB7" => '&#9573;',
109 "\xB8" => '&#9574;',
110 "\xB9" => '&#9575;',
111 "\xBA" => '&#9576;',
112 "\xBB" => '&#9577;',
113 "\xBC" => '&#9578;',
114 "\xBD" => '&#9579;',
115 "\xBE" => '&#9580;',
116 "\xBF" => '&#169;',
117 "\xC0" => '&#1102;',
118 "\xC1" => '&#1072;',
119 "\xC2" => '&#1073;',
120 "\xC3" => '&#1094;',
121 "\xC4" => '&#1076;',
122 "\xC5" => '&#1077;',
123 "\xC6" => '&#1092;',
124 "\xC7" => '&#1075;',
125 "\xC8" => '&#1093;',
126 "\xC9" => '&#1080;',
127 "\xCA" => '&#1081;',
128 "\xCB" => '&#1082;',
129 "\xCC" => '&#1083;',
130 "\xCD" => '&#1084;',
131 "\xCE" => '&#1085;',
132 "\xCF" => '&#1086;',
133 "\xD0" => '&#1087;',
134 "\xD1" => '&#1103;',
135 "\xD2" => '&#1088;',
136 "\xD3" => '&#1089;',
137 "\xD4" => '&#1090;',
138 "\xD5" => '&#1091;',
139 "\xD6" => '&#1078;',
140 "\xD7" => '&#1074;',
141 "\xD8" => '&#1100;',
142 "\xD9" => '&#1099;',
143 "\xDA" => '&#1079;',
144 "\xDB" => '&#1096;',
145 "\xDC" => '&#1101;',
146 "\xDD" => '&#1097;',
147 "\xDE" => '&#1095;',
148 "\xDF" => '&#1098;',
149 "\xE0" => '&#1070;',
150 "\xE1" => '&#1040;',
151 "\xE2" => '&#1041;',
152 "\xE3" => '&#1062;',
153 "\xE4" => '&#1044;',
154 "\xE5" => '&#1045;',
155 "\xE6" => '&#1060;',
156 "\xE7" => '&#1043;',
157 "\xE8" => '&#1061;',
158 "\xE9" => '&#1048;',
159 "\xEA" => '&#1049;',
160 "\xEB" => '&#1050;',
161 "\xEC" => '&#1051;',
162 "\xED" => '&#1052;',
163 "\xEE" => '&#1053;',
164 "\xEF" => '&#1054;',
165 "\xF0" => '&#1055;',
166 "\xF1" => '&#1071;',
167 "\xF2" => '&#1056;',
168 "\xF3" => '&#1057;',
169 "\xF4" => '&#1058;',
170 "\xF5" => '&#1059;',
171 "\xF6" => '&#1046;',
172 "\xF7" => '&#1042;',
173 "\xF8" => '&#1068;',
174 "\xF9" => '&#1067;',
175 "\xFA" => '&#1047;',
176 "\xFB" => '&#1064;',
177 "\xFC" => '&#1069;',
178 "\xFD" => '&#1065;',
179 "\xFE" => '&#1063;',
180 "\xFF" => '&#1066;'
181 );
182
183 $string = str_replace(array_keys($koi8r), array_values($koi8r), $string);
184
185 return $string;
186 }
187 ?>