us_ascii.php 1.1 KB

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