Source for file iso_8859_9.php

Documentation is available at iso_8859_9.php

  1. <?php
  2.  
  3. /**
  4.  * iso-8859-9 encoding functions
  5.  *
  6.  * takes a string of unicode entities and converts it to a iso-8859-9 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_9.php 14840 2020-01-07 07:42:38Z pdontthink $
  12.  * @package squirrelmail
  13.  * @subpackage encode
  14.  */
  15.  
  16. /**
  17.  * Converts string to iso-8859-9
  18.  * @param string $string text with numeric unicode entities
  19.  * @return string iso-8859-9 encoded text
  20.  */
  21. function charset_encode_iso_8859_9 ($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]+);/",'unicodetoiso88599',$string);
  26.  
  27.     return $string;
  28. }
  29.  
  30. /**
  31.  * Return iso-8859-9 symbol when unicode character number is provided
  32.  *
  33.  * This function is used internally by charset_encode_iso_8859_9
  34.  * function. It might be unavailable to other SquirrelMail functions.
  35.  * Don't use it or make sure, that functions/encode/iso_8859_9.php is
  36.  * included.
  37.  *
  38.  * @param array $matches array with first element a decimal unicode value
  39.  * @return string iso-8859-9 character
  40.  */
  41. function unicodetoiso88599($matches{
  42.     $var $matches[1];
  43.  
  44.     $iso88599chars=array('160' => "\xA0",
  45.                          '161' => "\xA1",
  46.                          '162' => "\xA2",
  47.                          '163' => "\xA3",
  48.                          '164' => "\xA4",
  49.                          '165' => "\xA5",
  50.                          '166' => "\xA6",
  51.                          '167' => "\xA7",
  52.                          '168' => "\xA8",
  53.                          '169' => "\xA9",
  54.                          '170' => "\xAA",
  55.                          '171' => "\xAB",
  56.                          '172' => "\xAC",
  57.                          '173' => "\xAD",
  58.                          '174' => "\xAE",
  59.                          '175' => "\xAF",
  60.                          '176' => "\xB0",
  61.                          '177' => "\xB1",
  62.                          '178' => "\xB2",
  63.                          '179' => "\xB3",
  64.                          '180' => "\xB4",
  65.                          '181' => "\xB5",
  66.                          '182' => "\xB6",
  67.                          '183' => "\xB7",
  68.                          '184' => "\xB8",
  69.                          '185' => "\xB9",
  70.                          '186' => "\xBA",
  71.                          '187' => "\xBB",
  72.                          '188' => "\xBC",
  73.                          '189' => "\xBD",
  74.                          '190' => "\xBE",
  75.                          '191' => "\xBF",
  76.                          '192' => "\xC0",
  77.                          '193' => "\xC1",
  78.                          '194' => "\xC2",
  79.                          '195' => "\xC3",
  80.                          '196' => "\xC4",
  81.                          '197' => "\xC5",
  82.                          '198' => "\xC6",
  83.                          '199' => "\xC7",
  84.                          '200' => "\xC8",
  85.                          '201' => "\xC9",
  86.                          '202' => "\xCA",
  87.                          '203' => "\xCB",
  88.                          '204' => "\xCC",
  89.                          '205' => "\xCD",
  90.                          '206' => "\xCE",
  91.                          '207' => "\xCF",
  92.                          '209' => "\xD1",
  93.                          '210' => "\xD2",
  94.                          '211' => "\xD3",
  95.                          '212' => "\xD4",
  96.                          '213' => "\xD5",
  97.                          '214' => "\xD6",
  98.                          '215' => "\xD7",
  99.                          '216' => "\xD8",
  100.                          '217' => "\xD9",
  101.                          '218' => "\xDA",
  102.                          '219' => "\xDB",
  103.                          '220' => "\xDC",
  104.                          '223' => "\xDF",
  105.                          '224' => "\xE0",
  106.                          '225' => "\xE1",
  107.                          '226' => "\xE2",
  108.                          '227' => "\xE3",
  109.                          '228' => "\xE4",
  110.                          '229' => "\xE5",
  111.                          '230' => "\xE6",
  112.                          '231' => "\xE7",
  113.                          '232' => "\xE8",
  114.                          '233' => "\xE9",
  115.                          '234' => "\xEA",
  116.                          '235' => "\xEB",
  117.                          '236' => "\xEC",
  118.                          '237' => "\xED",
  119.                          '238' => "\xEE",
  120.                          '239' => "\xEF",
  121.                          '241' => "\xF1",
  122.                          '242' => "\xF2",
  123.                          '243' => "\xF3",
  124.                          '244' => "\xF4",
  125.                          '245' => "\xF5",
  126.                          '246' => "\xF6",
  127.                          '247' => "\xF7",
  128.                          '248' => "\xF8",
  129.                          '249' => "\xF9",
  130.                          '250' => "\xFA",
  131.                          '251' => "\xFB",
  132.                          '252' => "\xFC",
  133.                          '255' => "\xFF",
  134.                          '286' => "\xD0",
  135.                          '287' => "\xF0",
  136.                          '304' => "\xDD",
  137.                          '305' => "\xFD",
  138.                          '350' => "\xDE",
  139.                          '351' => "\xFE");
  140.  
  141.  
  142.     if (array_key_exists($var,$iso88599chars)) {
  143.         $ret=$iso88599chars[$var];
  144.     else {
  145.         $ret='?';
  146.     }
  147.     return $ret;
  148. }

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