| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * functions/decode/us_ascii.php |
| 5 | * |
| 6 | * Copyright (c) 2004-2005 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 | * @version $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 | */ |
| 25 | function charset_decode_us_ascii ($string) { |
| 26 | // don't do decoding when there are no 8bit symbols |
| 27 | if (! sq_is8bit($string,'us-ascii')) |
| 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 | } |
| 38 | ?> |