us_ascii.php 998 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. /**
  3. * functions/decode/us_ascii.php
  4. *
  5. * Copyright (c) 2004-2005 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. // don't do decoding when there are no 8bit symbols
  25. if (! sq_is8bit($string,'us-ascii'))
  26. return $string;
  27. $string = preg_replace("/([\201-\237])/e","'?'",$string);
  28. /* I don't want to use 0xA0 (\240) in any ranges. RH73 may dislike it */
  29. $string = str_replace("\240", '?', $string);
  30. $string = preg_replace("/([\241-\377])/e","'?'",$string);
  31. return $string;
  32. }
  33. ?>