d672fcab |
1 | <?php |
2 | /* |
3 | * decode/iso8859-1.php |
4 | * $Id$ |
5 | * |
0a708025 |
6 | * Copyright (c) 2003 The SquirrelMail Project Team |
d672fcab |
7 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
8 | * |
9 | * This file contains iso-8859-1 decoding function that is needed to read |
10 | * iso-8859-1 encoded mails in non-iso-8859-1 locale. |
11 | * |
12 | */ |
13 | function charset_decode_iso8859_1 ($string) { |
14 | global $default_charset; |
15 | |
16 | if (strtolower($default_charset) == 'iso-8859-1') |
17 | return $string; |
18 | |
19 | /* Only do the slow convert if there are 8-bit characters */ |
20 | /* there is no 0x80-0x9F letters in ISO8859-* */ |
21 | if ( ! ereg("[\241-\377]", $string) ) |
22 | return $string; |
23 | |
24 | $string = preg_replace("/([\201-\237])/e","'&#' . ord('\\1') . ';'",$string); |
25 | |
26 | /* I don't want to use 0xA0 (\240) in any ranges. RH73 may dislike it */ |
27 | $string = str_replace("\240", ' ', $string); |
28 | |
29 | $string = preg_replace("/([\241-\377])/e","'&#' . ord('\\1') . ';'",$string); |
30 | return $string; |
31 | } |
32 | |
33 | ?> |