6bf8c5c7859c98df29f25d5baf38cbab421ae015
[squirrelmail.git] / functions / decode / us_ascii.php
1 <?php
2
3 /**
4 * functions/decode/us_ascii.php
5 *
6 * This file contains us-ascii decoding function that is needed to read
7 * us-ascii encoded mails in non-us-ascii locale.
8 *
9 * Function replaces all 8bit symbols with '?' marks
10 *
11 * @copyright 2004-2019 The SquirrelMail Project Team
12 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
13 * @version $Id$
14 * @package squirrelmail
15 * @subpackage decode
16 */
17
18 /**
19 * us-ascii decoding function.
20 *
21 * @param string $string string that has to be cleaned
22 * @return string cleaned string
23 */
24 function charset_decode_us_ascii ($string) {
25 // don't do decoding when there are no 8bit symbols
26 if (! sq_is8bit($string,'us-ascii'))
27 return $string;
28
29 $string = preg_replace("/([\201-\237])/","'?'",$string);
30
31 /* I don't want to use 0xA0 (\240) in any ranges. RH73 may dislike it */
32 $string = str_replace("\240", '?', $string);
33
34 $string = preg_replace("/([\241-\377])/","'?'",$string);
35 return $string;
36 }