Adding last two functions from i18n.php
[squirrelmail.git] / functions / decode / us_ascii.php
CommitLineData
d5bb4a01 1<?php
2
3/**
4 * functions/decode/us_ascii.php
5 *
6 * Copyright (c) 2004 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
8 *
9 * This file contains us-ascii decoding function that is needed to read
10 * us-ascii encoded mails in non-us-ascii locale.
11 *
12 * Function replaces all 8bit symbols with '?' marks
13 *
14 * $Id$
15 * @package squirrelmail
16 * @subpackage decode
17 */
18
19/**
20 * us-ascii decoding function.
21 *
22 * @param string $string string that has to be cleaned
23 * @return string cleaned string
24 */
25function charset_decode_us_ascii ($string) {
26 global $default_charset;
27
28 if (strtolower($default_charset) == 'us-ascii')
29 return $string;
30
31 if (! ereg("[\200-\237]", $string) and ! ereg("[\241-\377]", $string) )
32 return $string;
33
34 $string = preg_replace("/([\201-\237])/e","'?'",$string);
35
36 /* I don't want to use 0xA0 (\240) in any ranges. RH73 may dislike it */
37 $string = str_replace("\240", '?', $string);
38
39 $string = preg_replace("/([\241-\377])/e","'?'",$string);
40 return $string;
41}
42?>