6 * Copyright (c) 2003 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
9 * This file contains koi8-u decoding function that is needed to read
10 * koi8-u encoded mails in non-koi8-u locale.
12 * Original data taken from rfc2319
16 * Copyright (C) The Internet Society (1998). All Rights Reserved.
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
32 * The limited permissions granted above are perpetual and will not be
33 * revoked by the Internet Society or its successors or assigns.
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.
42 * @package squirrelmail
47 * Decode koi8-u encoded strings
48 * @param string $string Encoded string
49 * @return string Decoded string
51 function charset_decode_koi8_u ($string) {
52 global $default_charset;
54 if (strtolower($default_charset) == 'koi8-u')
57 /* Only do the slow convert if there are 8-bit characters */
58 /* avoid using 0xA0 (\240) in ereg ranges. RH73 does not like that */
59 if (! ereg("[\200-\237]", $string) and ! ereg("[\241-\377]", $string) )
193 $string = str_replace(array_keys($koi8u), array_values($koi8u), $string);