us_ascii.php 998 B

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