fixed warning
[squirrelmail.git] / functions / decode / koi8-u.php
CommitLineData
0a708025 1<?php
2/*
3 * decode/koi8-u.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-u decoding function that is needed to read
10 * koi8-u encoded mails in non-koi8-u locale.
11 *
12 * Original data taken from rfc2319
13 *
14 * Original copyright:
15 *
16 * Copyright (C) The Internet Society (1998). All Rights Reserved.
17 *
18 * This document and translations of it may be copied and furnished to
19 * others, and derivative works that comment on or otherwise explain it
20 * or assist in its implementation may be prepared, copied, published
21 * and distributed, in whole or in part, without restriction of any
22 * kind, provided that the above copyright notice and this paragraph are
23 * included on all such copies and derivative works. However, this
24 * document itself may not be modified in any way, such as by removing
25 * the copyright notice or references to the Internet Society or other
26 * Internet organizations, except as needed for the purpose of
27 * developing Internet standards in which case the procedures for
28 * copyrights defined in the Internet Standards process must be
29 * followed, or as required to translate it into languages other than
30 * English.
31 *
32 * The limited permissions granted above are perpetual and will not be
33 * revoked by the Internet Society or its successors or assigns.
34 *
35 * This document and the information contained herein is provided on an
36 * "AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING
37 * TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
38 * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
39 * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
40 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
41 *
42 */
43function charset_decode_koi8u ($string) {
44 global $default_charset;
45
46 if (strtolower($default_charset) == 'koi8-u')
47 return $string;
48
49 /* Only do the slow convert if there are 8-bit characters */
50 /* avoid using 0xA0 (\240) in ereg ranges. RH73 does not like that */
51 if (! ereg("[\200-\237]", $string) and ! ereg("[\241-\377]", $string) )
52 return $string;
53
54 $koi8u = array(
55 "\x80" => '&#9472;',
56 "\x81" => '&#9474;',
57 "\x82" => '&#9484;',
58 "\x83" => '&#9488;',
59 "\x84" => '&#9492;',
60 "\x85" => '&#9496;',
61 "\x86" => '&#9500;',
62 "\x87" => '&#9508;',
63 "\x88" => '&#9516;',
64 "\x89" => '&#9524;',
65 "\x8A" => '&#9532;',
66 "\x8B" => '&#9600;',
67 "\x8C" => '&#9604;',
68 "\x8D" => '&#9608;',
69 "\x8E" => '&#9612;',
70 "\x8F" => '&#9616;',
71 "\x90" => '&#9617;',
72 "\x91" => '&#9618;',
73 "\x92" => '&#9619;',
74 "\x93" => '&#8992;',
75 "\x94" => '&#9632;',
76 "\x95" => '&#8729;',
77 "\x96" => '&#8730;',
78 "\x97" => '&#8776;',
79 "\x98" => '&#8804;',
80 "\x99" => '&#8805;',
81 "\x9A" => '&#160;',
82 "\x9B" => '&#8993;',
83 "\x9C" => '&#176;',
84 "\x9D" => '&#178;',
85 "\x9E" => '&#183;',
86 "\x9F" => '&#247;',
87 "\xA0" => '&#9552;',
88 "\xA1" => '&#9553;',
89 "\xA2" => '&#9554;',
90 "\xA3" => '&#1105;',
91 "\xA4" => '&#1108;',
92 "\xA5" => '&#9556;',
93 "\xA6" => '&#1110;',
94 "\xA7" => '&#1111;',
95 "\xA8" => '&#9559;',
96 "\xA9" => '&#9560;',
97 "\xAA" => '&#9561;',
98 "\xAB" => '&#9562;',
99 "\xAC" => '&#9563;',
100 "\xAD" => '&#1169;',
101 "\xAE" => '&#9565;',
102 "\xAF" => '&#9566;',
103 "\xB0" => '&#9567;',
104 "\xB1" => '&#9568;',
105 "\xB2" => '&#9569;',
106 "\xB3" => '&#1025;',
107 "\xB4" => '&#1027;',
108 "\xB5" => '&#9571;',
109 "\xB6" => '&#1030;',
110 "\xB7" => '&#1031;',
111 "\xB8" => '&#9574;',
112 "\xB9" => '&#9575;',
113 "\xBA" => '&#9576;',
114 "\xBB" => '&#9577;',
115 "\xBC" => '&#9578;',
116 "\xBD" => '&#1168;',
117 "\xBE" => '&#9580;',
118 "\xBF" => '&#169;',
119 "\xC0" => '&#1102;',
120 "\xC1" => '&#1072;',
121 "\xC2" => '&#1073;',
122 "\xC3" => '&#1094;',
123 "\xC4" => '&#1076;',
124 "\xC5" => '&#1077;',
125 "\xC6" => '&#1092;',
126 "\xC7" => '&#1075;',
127 "\xC8" => '&#1093;',
128 "\xC9" => '&#1080;',
129 "\xCA" => '&#1081;',
130 "\xCB" => '&#1082;',
131 "\xCC" => '&#1083;',
132 "\xCD" => '&#1084;',
133 "\xCE" => '&#1085;',
134 "\xCF" => '&#1086;',
135 "\xD0" => '&#1087;',
136 "\xD1" => '&#1103;',
137 "\xD2" => '&#1088;',
138 "\xD3" => '&#1089;',
139 "\xD4" => '&#1090;',
140 "\xD5" => '&#1091;',
141 "\xD6" => '&#1078;',
142 "\xD7" => '&#1074;',
143 "\xD8" => '&#1100;',
144 "\xD9" => '&#1099;',
145 "\xDA" => '&#1079;',
146 "\xDB" => '&#1096;',
147 "\xDC" => '&#1101;',
148 "\xDD" => '&#1097;',
149 "\xDE" => '&#1095;',
150 "\xDF" => '&#1098;',
151 "\xE0" => '&#1070;',
152 "\xE1" => '&#1040;',
153 "\xE2" => '&#1041;',
154 "\xE3" => '&#1062;',
155 "\xE4" => '&#1044;',
156 "\xE5" => '&#1045;',
157 "\xE6" => '&#1060;',
158 "\xE7" => '&#1043;',
159 "\xE8" => '&#1061;',
160 "\xE9" => '&#1048;',
161 "\xEA" => '&#1049;',
162 "\xEB" => '&#1050;',
163 "\xEC" => '&#1051;',
164 "\xED" => '&#1052;',
165 "\xEE" => '&#1053;',
166 "\xEF" => '&#1054;',
167 "\xF0" => '&#1055;',
168 "\xF1" => '&#1071;',
169 "\xF2" => '&#1056;',
170 "\xF3" => '&#1057;',
171 "\xF4" => '&#1058;',
172 "\xF5" => '&#1059;',
173 "\xF6" => '&#1046;',
174 "\xF7" => '&#1042;',
175 "\xF8" => '&#1068;',
176 "\xF9" => '&#1067;',
177 "\xFA" => '&#1047;',
178 "\xFB" => '&#1064;',
179 "\xFC" => '&#1069;',
180 "\xFD" => '&#1065;',
181 "\xFE" => '&#1063;',
182 "\xFF" => '&#1066;'
183 );
184
185 $string = str_replace(array_keys($koi8u), array_values($koi8u), $string);
186
187 return $string;
188}
189
190?>