us_ascii.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. if (! ereg("[\200-\237]", $string) and ! ereg("[\241-\377]", $string) )
  28. return $string;
  29. $string = preg_replace("/([\201-\237])/e","'?'",$string);
  30. /* I don't want to use 0xA0 (\240) in any ranges. RH73 may dislike it */
  31. $string = str_replace("\240", '?', $string);
  32. $string = preg_replace("/([\241-\377])/e","'?'",$string);
  33. return $string;
  34. }
  35. ?>