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