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 iso-8859-1 decoding function that is needed to read
9 * iso-8859-1 encoded mails in non-iso-8859-1 locale.
12 * @package squirrelmail
17 * Decode iso8859-1 string
18 * @param string $string Encoded string
19 * @return string $string Decoded string
21 function charset_decode_iso_8859_1 ($string) {
22 global $default_charset;
24 if (strtolower($default_charset) == 'iso-8859-1')
27 /* Only do the slow convert if there are 8-bit characters */
28 /* there is no 0x80-0x9F letters in ISO8859-* */
29 if ( ! ereg("[\241-\377]", $string) )
32 $string = preg_replace("/([\201-\237])/e","'&#' . ord('\\1') . ';'",$string);
34 /* I don't want to use 0xA0 (\240) in any ranges. RH73 may dislike it */
35 $string = str_replace("\240", ' ', $string);
37 $string = preg_replace("/([\241-\377])/e","'&#' . ord('\\1') . ';'",$string);