iso_8859_1.php 983 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. /**
  3. * decode/iso8859-1.php
  4. *
  5. * This file contains iso-8859-1 decoding function that is needed to read
  6. * iso-8859-1 encoded mails in non-iso-8859-1 locale.
  7. *
  8. * @copyright &copy; 2003-2006 The SquirrelMail Project Team
  9. * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  10. * @version $Id$
  11. * @package squirrelmail
  12. * @subpackage decode
  13. */
  14. /**
  15. * Decode iso8859-1 string
  16. * @param string $string Encoded string
  17. * @return string $string Decoded string
  18. */
  19. function charset_decode_iso_8859_1 ($string) {
  20. // don't do decoding when there are no 8bit symbols
  21. if (! sq_is8bit($string,'iso-8859-1'))
  22. return $string;
  23. $string = preg_replace("/([\201-\237])/e","'&#' . ord('\\1') . ';'",$string);
  24. /* I don't want to use 0xA0 (\240) in any ranges. RH73 may dislike it */
  25. $string = str_replace("\240", '&#160;', $string);
  26. $string = preg_replace("/([\241-\377])/e","'&#' . ord('\\1') . ';'",$string);
  27. return $string;
  28. }