Preparation to begin using phpdocumentor.
[squirrelmail.git] / functions / decode / iso8859-1.php
CommitLineData
d672fcab 1<?php
d6c32258 2/**
d672fcab 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.
d6c32258 11 * @package squirrelmail
12 * @subpackage decode
13 */
14
15/**
16 * Decode iso8859-1 string
17 * @param string $string Encoded string
18 * @return string $string Decoded string
d672fcab 19 */
20function charset_decode_iso8859_1 ($string) {
21 global $default_charset;
22
23 if (strtolower($default_charset) == 'iso-8859-1')
24 return $string;
25
26 /* Only do the slow convert if there are 8-bit characters */
27 /* there is no 0x80-0x9F letters in ISO8859-* */
28 if ( ! ereg("[\241-\377]", $string) )
29 return $string;
30
31 $string = preg_replace("/([\201-\237])/e","'&#' . ord('\\1') . ';'",$string);
32
33 /* I don't want to use 0xA0 (\240) in any ranges. RH73 may dislike it */
34 $string = str_replace("\240", '&#160;', $string);
35
36 $string = preg_replace("/([\241-\377])/e","'&#' . ord('\\1') . ';'",$string);
37 return $string;
38}
39
d6c32258 40?>