removing default_charset tests. code can be reused in main function and
[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 *
31841a9e 14 * @version $Id$
d5bb4a01 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) {
e53c9681 26 // don't do decoding when there are no 8bit symbols
27 if (! sq_is8bit($string,'us-ascii'))
d5bb4a01 28 return $string;
29
30 $string = preg_replace("/([\201-\237])/e","'?'",$string);
31
32 /* I don't want to use 0xA0 (\240) in any ranges. RH73 may dislike it */
33 $string = str_replace("\240", '?', $string);
34
35 $string = preg_replace("/([\241-\377])/e","'?'",$string);
36 return $string;
37}
e53c9681 38?>