Source for file iso_8859_2.php

Documentation is available at iso_8859_2.php

  1. <?php
  2.  
  3. /**
  4.  * iso-8859-2 encoding functions
  5.  *
  6.  * takes a string of unicode entities and converts it to a iso-8859-2 encoded string
  7.  * Unsupported characters are replaced with ?.
  8.  *
  9.  * @copyright 2004-2014 The SquirrelMail Project Team
  10.  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  11.  * @version $Id: iso_8859_2.php 14422 2014-01-01 20:59:43Z pdontthink $
  12.  * @package squirrelmail
  13.  * @subpackage encode
  14.  */
  15.  
  16. /**
  17.  * Converts string to iso-8859-2
  18.  * @param string $string text with numeric unicode entities
  19.  * @return string iso-8859-2 encoded text
  20.  */
  21. function charset_encode_iso_8859_2 ($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]+);/",'unicodetoiso88592',$string);
  26.  
  27.     return $string;
  28. }
  29.  
  30. /**
  31.  * Return iso-8859-2 symbol when unicode character number is provided
  32.  *
  33.  * This function is used internally by charset_encode_iso_8859_2
  34.  * function. It might be unavailable to other SquirrelMail functions.
  35.  * Don't use it or make sure, that functions/encode/iso_8859_2.php is
  36.  * included.
  37.  *
  38.  * @param array $matches array with first element a decimal unicode value
  39.  * @return string iso-8859-2 character
  40.  */
  41. function unicodetoiso88592($matches{
  42.     $var $matches[1];
  43.  
  44.     $iso88592chars=array('160' => "\xA0",
  45.                         '164' => "\xA4",
  46.                         '167' => "\xA7",
  47.                         '168' => "\xA8",
  48.                         '173' => "\xAD",
  49.                         '176' => "\xB0",
  50.                         '180' => "\xB4",
  51.                         '184' => "\xB8",
  52.                         '193' => "\xC1",
  53.                         '194' => "\xC2",
  54.                         '196' => "\xC4",
  55.                         '199' => "\xC7",
  56.                         '201' => "\xC9",
  57.                         '203' => "\xCB",
  58.                         '205' => "\xCD",
  59.                         '206' => "\xCE",
  60.                         '211' => "\xD3",
  61.                         '212' => "\xD4",
  62.                         '214' => "\xD6",
  63.                         '215' => "\xD7",
  64.                         '218' => "\xDA",
  65.                         '220' => "\xDC",
  66.                         '221' => "\xDD",
  67.                         '223' => "\xDF",
  68.                         '225' => "\xE1",
  69.                         '226' => "\xE2",
  70.                         '228' => "\xE4",
  71.                         '231' => "\xE7",
  72.                         '233' => "\xE9",
  73.                         '235' => "\xEB",
  74.                         '237' => "\xED",
  75.                         '238' => "\xEE",
  76.                         '243' => "\xF3",
  77.                         '244' => "\xF4",
  78.                         '246' => "\xF6",
  79.                         '247' => "\xF7",
  80.                         '250' => "\xFA",
  81.                         '252' => "\xFC",
  82.                         '253' => "\xFD",
  83.                         '258' => "\xC3",
  84.                         '259' => "\xE3",
  85.                         '260' => "\xA1",
  86.                         '261' => "\xB1",
  87.                         '262' => "\xC6",
  88.                         '263' => "\xE6",
  89.                         '268' => "\xC8",
  90.                         '269' => "\xE8",
  91.                         '270' => "\xCF",
  92.                         '271' => "\xEF",
  93.                         '272' => "\xD0",
  94.                         '273' => "\xF0",
  95.                         '280' => "\xCA",
  96.                         '281' => "\xEA",
  97.                         '282' => "\xCC",
  98.                         '283' => "\xEC",
  99.                         '313' => "\xC5",
  100.                         '314' => "\xE5",
  101.                         '317' => "\xA5",
  102.                         '318' => "\xB5",
  103.                         '321' => "\xA3",
  104.                         '322' => "\xB3",
  105.                         '323' => "\xD1",
  106.                         '324' => "\xF1",
  107.                         '327' => "\xD2",
  108.                         '328' => "\xF2",
  109.                         '336' => "\xD5",
  110.                         '337' => "\xF5",
  111.                         '340' => "\xC0",
  112.                         '341' => "\xE0",
  113.                         '344' => "\xD8",
  114.                         '345' => "\xF8",
  115.                         '346' => "\xA6",
  116.                         '347' => "\xB6",
  117.                         '350' => "\xAA",
  118.                         '351' => "\xBA",
  119.                         '352' => "\xA9",
  120.                         '353' => "\xB9",
  121.                         '354' => "\xDE",
  122.                         '355' => "\xFE",
  123.                         '356' => "\xAB",
  124.                         '357' => "\xBB",
  125.                         '366' => "\xD9",
  126.                         '367' => "\xF9",
  127.                         '368' => "\xDB",
  128.                         '369' => "\xFB",
  129.                         '377' => "\xAC",
  130.                         '378' => "\xBC",
  131.                         '379' => "\xAF",
  132.                         '380' => "\xBF",
  133.                         '381' => "\xAE",
  134.                         '382' => "\xBE",
  135.                         '711' => "\xB7",
  136.                         '728' => "\xA2",
  137.                         '729' => "\xFF",
  138.                         '731' => "\xB2",
  139.                         '733' => "\xBD");
  140.  
  141.  
  142.     if (array_key_exists($var,$iso88592chars)) {
  143.         $ret=$iso88592chars[$var];
  144.     else {
  145.         $ret='?';
  146.     }
  147.     return $ret;
  148. }

Documentation generated on Wed, 23 Apr 2014 04:21:01 +0200 by phpDocumentor 1.4.3