Source for file iso_8859_1.php

Documentation is available at iso_8859_1.php

  1. <?php
  2.  
  3. /**
  4.  * iso-8859-1 encoding functions
  5.  *
  6.  * takes a string of unicode entities and converts it to a iso-8859-1 encoded string
  7.  * Unsupported characters are replaced with ?.
  8.  *
  9.  * @copyright 2004-2020 The SquirrelMail Project Team
  10.  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  11.  * @version $Id: iso_8859_1.php 14845 2020-01-07 08:09:34Z pdontthink $
  12.  * @package squirrelmail
  13.  * @subpackage encode
  14.  */
  15.  
  16. /**
  17.  * Converts string to iso-8859-1
  18.  * @param string $string text with numeric unicode entities
  19.  * @return string iso-8859-1 encoded text
  20.  */
  21. function charset_encode_iso_8859_1 ($string{
  22.    // don't run encoding function, if there is no encoded characters
  23.    if (preg_match("'&#[0-9]+;'",$string) ) return $string;
  24.  
  25.     $string=preg_replace_callback("/&#([0-9]+);/",'unicodetoiso88591',$string);
  26.  
  27.     return $string;
  28. }
  29.  
  30. /**
  31.  * Return iso-8859-1 symbol when unicode character number is provided
  32.  *
  33.  * This function is used internally by charset_encode_iso_8859_1
  34.  * function. It might be unavailable to other SquirrelMail functions.
  35.  * Don't use it or make sure, that functions/encode/iso_8859_1.php is
  36.  * included.
  37.  *
  38.  * @param array $matches array with first element a decimal unicode value
  39.  * @return string iso-8859-1 character
  40.  */
  41. function unicodetoiso88591($matches{
  42.     $var $matches[1];
  43.  
  44.     if ($var 256{
  45.         $ret chr ($var);
  46.     else {
  47.         $ret='?';
  48.     }
  49.     return $ret;
  50. }

Documentation generated on Mon, 13 Jan 2020 04:22:50 +0100 by phpDocumentor 1.4.3