5 * Copyright (c) 2003-2004 The SquirrelMail Project Team
6 * Licensed under the GNU GPL. For full terms see the file COPYING.
8 * This file contains cp866 decoding function that is needed to read
9 * cp866 encoded mails in non-cp866 locale.
11 * Original data taken from:
12 * ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/
14 Name: cp866_DOSCyrillicRussian to Unicode table
17 Table format: Format A
19 Authors: Lori Brownell <loribr@microsoft.com>
20 K.D. Chang <a-kchang@microsoft.com>
21 The entries are in cp866_DOSCyrillicRussian order
24 * @package squirrelmail
29 * Decode a cp866-encoded string
30 * @param string $string Encoded string
31 * @return string $string Decoded string
33 function charset_decode_cp866 ($string) {
34 global $default_charset;
36 if (strtolower($default_charset) == 'ibm866')
39 /* Only do the slow convert if there are 8-bit characters */
40 /* avoid using 0xA0 (\240) in ereg ranges. RH73 does not like that */
41 if (! ereg("[\200-\237]", $string) and ! ereg("[\241-\377]", $string) )
175 $string = str_replace(array_keys($cp866), array_values($cp866), $string);