Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 310 and 401] [Versions 39 and 401] [Versions 401 and 402] [Versions 401 and 403]

   1  <?php
   2  /**
   3   * SimplePie
   4   *
   5   * A PHP-Based RSS and Atom Feed Framework.
   6   * Takes the hard work out of managing a complete RSS/Atom solution.
   7   *
   8   * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
   9   * All rights reserved.
  10   *
  11   * Redistribution and use in source and binary forms, with or without modification, are
  12   * permitted provided that the following conditions are met:
  13   *
  14   * 	 * Redistributions of source code must retain the above copyright notice, this list of
  15   * 	   conditions and the following disclaimer.
  16   *
  17   * 	 * Redistributions in binary form must reproduce the above copyright notice, this list
  18   * 	   of conditions and the following disclaimer in the documentation and/or other materials
  19   * 	   provided with the distribution.
  20   *
  21   * 	 * Neither the name of the SimplePie Team nor the names of its contributors may be used
  22   * 	   to endorse or promote products derived from this software without specific prior
  23   * 	   written permission.
  24   *
  25   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  26   * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
  27   * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
  28   * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  29   * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  30   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  31   * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  32   * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  33   * POSSIBILITY OF SUCH DAMAGE.
  34   *
  35   * @package SimplePie
  36   * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
  37   * @author Ryan Parman
  38   * @author Sam Sneddon
  39   * @author Ryan McCue
  40   * @link http://simplepie.org/ SimplePie
  41   * @license http://www.opensource.org/licenses/bsd-license.php BSD License
  42   */
  43  
  44  
  45  /**
  46   * Decode HTML Entities
  47   *
  48   * This implements HTML5 as of revision 967 (2007-06-28)
  49   *
  50   * @deprecated Use DOMDocument instead!
  51   * @package SimplePie
  52   */
  53  class SimplePie_Decode_HTML_Entities
  54  {
  55  	 /**
  56  	  * Data to be parsed
  57  	  *
  58  	  * @access private
  59  	  * @var string
  60  	  */
  61  	 var $data = '';
  62  
  63  	 /**
  64  	  * Currently consumed bytes
  65  	  *
  66  	  * @access private
  67  	  * @var string
  68  	  */
  69  	 var $consumed = '';
  70  
  71  	 /**
  72  	  * Position of the current byte being parsed
  73  	  *
  74  	  * @access private
  75  	  * @var int
  76  	  */
  77  	 var $position = 0;
  78  
  79  	 /**
  80  	  * Create an instance of the class with the input data
  81  	  *
  82  	  * @access public
  83  	  * @param string $data Input data
  84  	  */
  85  	public function __construct($data)
  86  	 {
  87  	 	 $this->data = $data;
  88  	 }
  89  
  90  	 /**
  91  	  * Parse the input data
  92  	  *
  93  	  * @access public
  94  	  * @return string Output data
  95  	  */
  96  	public function parse()
  97  	 {
  98  	 	 while (($this->position = strpos($this->data, '&', $this->position)) !== false)
  99  	 	 {
 100  	 	 	 $this->consume();
 101  	 	 	 $this->entity();
 102  	 	 	 $this->consumed = '';
 103  	 	 }
 104  	 	 return $this->data;
 105  	 }
 106  
 107  	 /**
 108  	  * Consume the next byte
 109  	  *
 110  	  * @access private
 111  	  * @return mixed The next byte, or false, if there is no more data
 112  	  */
 113  	public function consume()
 114  	 {
 115  	 	 if (isset($this->data[$this->position]))
 116  	 	 {
 117  	 	 	 $this->consumed .= $this->data[$this->position];
 118  	 	 	 return $this->data[$this->position++];
 119  	 	 }
 120  
 121  	 	 return false;
 122  	 }
 123  
 124  	 /**
 125  	  * Consume a range of characters
 126  	  *
 127  	  * @access private
 128  	  * @param string $chars Characters to consume
 129  	  * @return mixed A series of characters that match the range, or false
 130  	  */
 131  	public function consume_range($chars)
 132  	 {
 133  	 	 if ($len = strspn($this->data, $chars, $this->position))
 134  	 	 {
 135  	 	 	 $data = substr($this->data, $this->position, $len);
 136  	 	 	 $this->consumed .= $data;
 137  	 	 	 $this->position += $len;
 138  	 	 	 return $data;
 139  	 	 }
 140  
 141  	 	 return false;
 142  	 }
 143  
 144  	 /**
 145  	  * Unconsume one byte
 146  	  *
 147  	  * @access private
 148  	  */
 149  	public function unconsume()
 150  	 {
 151  	 	 $this->consumed = substr($this->consumed, 0, -1);
 152  	 	 $this->position--;
 153  	 }
 154  
 155  	 /**
 156  	  * Decode an entity
 157  	  *
 158  	  * @access private
 159  	  */
 160  	public function entity()
 161  	 {
 162  	 	 switch ($this->consume())
 163  	 	 {
 164  	 	 	 case "\x09":
 165  	 	 	 case "\x0A":
 166  	 	 	 case "\x0B":
 167  	 	 	 case "\x0C":
 168  	 	 	 case "\x20":
 169  	 	 	 case "\x3C":
 170  	 	 	 case "\x26":
 171  	 	 	 case false:
 172  	 	 	 	 break;
 173  
 174  	 	 	 case "\x23":
 175  	 	 	 	 switch ($this->consume())
 176  	 	 	 	 {
 177  	 	 	 	 	 case "\x78":
 178  	 	 	 	 	 case "\x58":
 179  	 	 	 	 	 	 $range = '0123456789ABCDEFabcdef';
 180  	 	 	 	 	 	 $hex = true;
 181  	 	 	 	 	 	 break;
 182  
 183  	 	 	 	 	 default:
 184  	 	 	 	 	 	 $range = '0123456789';
 185  	 	 	 	 	 	 $hex = false;
 186  	 	 	 	 	 	 $this->unconsume();
 187  	 	 	 	 	 	 break;
 188  	 	 	 	 }
 189  
 190  	 	 	 	 if ($codepoint = $this->consume_range($range))
 191  	 	 	 	 {
 192  	 	 	 	 	 static $windows_1252_specials = array(0x0D => "\x0A", 0x80 => "\xE2\x82\xAC", 0x81 => "\xEF\xBF\xBD", 0x82 => "\xE2\x80\x9A", 0x83 => "\xC6\x92", 0x84 => "\xE2\x80\x9E", 0x85 => "\xE2\x80\xA6", 0x86 => "\xE2\x80\xA0", 0x87 => "\xE2\x80\xA1", 0x88 => "\xCB\x86", 0x89 => "\xE2\x80\xB0", 0x8A => "\xC5\xA0", 0x8B => "\xE2\x80\xB9", 0x8C => "\xC5\x92", 0x8D => "\xEF\xBF\xBD", 0x8E => "\xC5\xBD", 0x8F => "\xEF\xBF\xBD", 0x90 => "\xEF\xBF\xBD", 0x91 => "\xE2\x80\x98", 0x92 => "\xE2\x80\x99", 0x93 => "\xE2\x80\x9C", 0x94 => "\xE2\x80\x9D", 0x95 => "\xE2\x80\xA2", 0x96 => "\xE2\x80\x93", 0x97 => "\xE2\x80\x94", 0x98 => "\xCB\x9C", 0x99 => "\xE2\x84\xA2", 0x9A => "\xC5\xA1", 0x9B => "\xE2\x80\xBA", 0x9C => "\xC5\x93", 0x9D => "\xEF\xBF\xBD", 0x9E => "\xC5\xBE", 0x9F => "\xC5\xB8");
 193  
 194  	 	 	 	 	 if ($hex)
 195  	 	 	 	 	 {
 196  	 	 	 	 	 	 $codepoint = hexdec($codepoint);
 197  	 	 	 	 	 }
 198  	 	 	 	 	 else
 199  	 	 	 	 	 {
 200  	 	 	 	 	 	 $codepoint = intval($codepoint);
 201  	 	 	 	 	 }
 202  
 203  	 	 	 	 	 if (isset($windows_1252_specials[$codepoint]))
 204  	 	 	 	 	 {
 205  	 	 	 	 	 	 $replacement = $windows_1252_specials[$codepoint];
 206  	 	 	 	 	 }
 207  	 	 	 	 	 else
 208  	 	 	 	 	 {
 209  	 	 	 	 	 	 $replacement = SimplePie_Misc::codepoint_to_utf8($codepoint);
 210  	 	 	 	 	 }
 211  
 212  	 	 	 	 	 if (!in_array($this->consume(), array(';', false), true))
 213  	 	 	 	 	 {
 214  	 	 	 	 	 	 $this->unconsume();
 215  	 	 	 	 	 }
 216  
 217  	 	 	 	 	 $consumed_length = strlen($this->consumed);
 218  	 	 	 	 	 $this->data = substr_replace($this->data, $replacement, $this->position - $consumed_length, $consumed_length);
 219  	 	 	 	 	 $this->position += strlen($replacement) - $consumed_length;
 220  	 	 	 	 }
 221  	 	 	 	 break;
 222  
 223  	 	 	 default:
 224  	 	 	 	 static $entities = array(
 225  	 	 	 	 	 'Aacute' => "\xC3\x81",
 226  	 	 	 	 	 'aacute' => "\xC3\xA1",
 227  	 	 	 	 	 'Aacute;' => "\xC3\x81",
 228  	 	 	 	 	 'aacute;' => "\xC3\xA1",
 229  	 	 	 	 	 'Acirc' => "\xC3\x82",
 230  	 	 	 	 	 'acirc' => "\xC3\xA2",
 231  	 	 	 	 	 'Acirc;' => "\xC3\x82",
 232  	 	 	 	 	 'acirc;' => "\xC3\xA2",
 233  	 	 	 	 	 'acute' => "\xC2\xB4",
 234  	 	 	 	 	 'acute;' => "\xC2\xB4",
 235  	 	 	 	 	 'AElig' => "\xC3\x86",
 236  	 	 	 	 	 'aelig' => "\xC3\xA6",
 237  	 	 	 	 	 'AElig;' => "\xC3\x86",
 238  	 	 	 	 	 'aelig;' => "\xC3\xA6",
 239  	 	 	 	 	 'Agrave' => "\xC3\x80",
 240  	 	 	 	 	 'agrave' => "\xC3\xA0",
 241  	 	 	 	 	 'Agrave;' => "\xC3\x80",
 242  	 	 	 	 	 'agrave;' => "\xC3\xA0",
 243  	 	 	 	 	 'alefsym;' => "\xE2\x84\xB5",
 244  	 	 	 	 	 'Alpha;' => "\xCE\x91",
 245  	 	 	 	 	 'alpha;' => "\xCE\xB1",
 246  	 	 	 	 	 'AMP' => "\x26",
 247  	 	 	 	 	 'amp' => "\x26",
 248  	 	 	 	 	 'AMP;' => "\x26",
 249  	 	 	 	 	 'amp;' => "\x26",
 250  	 	 	 	 	 'and;' => "\xE2\x88\xA7",
 251  	 	 	 	 	 'ang;' => "\xE2\x88\xA0",
 252  	 	 	 	 	 'apos;' => "\x27",
 253  	 	 	 	 	 'Aring' => "\xC3\x85",
 254  	 	 	 	 	 'aring' => "\xC3\xA5",
 255  	 	 	 	 	 'Aring;' => "\xC3\x85",
 256  	 	 	 	 	 'aring;' => "\xC3\xA5",
 257  	 	 	 	 	 'asymp;' => "\xE2\x89\x88",
 258  	 	 	 	 	 'Atilde' => "\xC3\x83",
 259  	 	 	 	 	 'atilde' => "\xC3\xA3",
 260  	 	 	 	 	 'Atilde;' => "\xC3\x83",
 261  	 	 	 	 	 'atilde;' => "\xC3\xA3",
 262  	 	 	 	 	 'Auml' => "\xC3\x84",
 263  	 	 	 	 	 'auml' => "\xC3\xA4",
 264  	 	 	 	 	 'Auml;' => "\xC3\x84",
 265  	 	 	 	 	 'auml;' => "\xC3\xA4",
 266  	 	 	 	 	 'bdquo;' => "\xE2\x80\x9E",
 267  	 	 	 	 	 'Beta;' => "\xCE\x92",
 268  	 	 	 	 	 'beta;' => "\xCE\xB2",
 269  	 	 	 	 	 'brvbar' => "\xC2\xA6",
 270  	 	 	 	 	 'brvbar;' => "\xC2\xA6",
 271  	 	 	 	 	 'bull;' => "\xE2\x80\xA2",
 272  	 	 	 	 	 'cap;' => "\xE2\x88\xA9",
 273  	 	 	 	 	 'Ccedil' => "\xC3\x87",
 274  	 	 	 	 	 'ccedil' => "\xC3\xA7",
 275  	 	 	 	 	 'Ccedil;' => "\xC3\x87",
 276  	 	 	 	 	 'ccedil;' => "\xC3\xA7",
 277  	 	 	 	 	 'cedil' => "\xC2\xB8",
 278  	 	 	 	 	 'cedil;' => "\xC2\xB8",
 279  	 	 	 	 	 'cent' => "\xC2\xA2",
 280  	 	 	 	 	 'cent;' => "\xC2\xA2",
 281  	 	 	 	 	 'Chi;' => "\xCE\xA7",
 282  	 	 	 	 	 'chi;' => "\xCF\x87",
 283  	 	 	 	 	 'circ;' => "\xCB\x86",
 284  	 	 	 	 	 'clubs;' => "\xE2\x99\xA3",
 285  	 	 	 	 	 'cong;' => "\xE2\x89\x85",
 286  	 	 	 	 	 'COPY' => "\xC2\xA9",
 287  	 	 	 	 	 'copy' => "\xC2\xA9",
 288  	 	 	 	 	 'COPY;' => "\xC2\xA9",
 289  	 	 	 	 	 'copy;' => "\xC2\xA9",
 290  	 	 	 	 	 'crarr;' => "\xE2\x86\xB5",
 291  	 	 	 	 	 'cup;' => "\xE2\x88\xAA",
 292  	 	 	 	 	 'curren' => "\xC2\xA4",
 293  	 	 	 	 	 'curren;' => "\xC2\xA4",
 294  	 	 	 	 	 'Dagger;' => "\xE2\x80\xA1",
 295  	 	 	 	 	 'dagger;' => "\xE2\x80\xA0",
 296  	 	 	 	 	 'dArr;' => "\xE2\x87\x93",
 297  	 	 	 	 	 'darr;' => "\xE2\x86\x93",
 298  	 	 	 	 	 'deg' => "\xC2\xB0",
 299  	 	 	 	 	 'deg;' => "\xC2\xB0",
 300  	 	 	 	 	 'Delta;' => "\xCE\x94",
 301  	 	 	 	 	 'delta;' => "\xCE\xB4",
 302  	 	 	 	 	 'diams;' => "\xE2\x99\xA6",
 303  	 	 	 	 	 'divide' => "\xC3\xB7",
 304  	 	 	 	 	 'divide;' => "\xC3\xB7",
 305  	 	 	 	 	 'Eacute' => "\xC3\x89",
 306  	 	 	 	 	 'eacute' => "\xC3\xA9",
 307  	 	 	 	 	 'Eacute;' => "\xC3\x89",
 308  	 	 	 	 	 'eacute;' => "\xC3\xA9",
 309  	 	 	 	 	 'Ecirc' => "\xC3\x8A",
 310  	 	 	 	 	 'ecirc' => "\xC3\xAA",
 311  	 	 	 	 	 'Ecirc;' => "\xC3\x8A",
 312  	 	 	 	 	 'ecirc;' => "\xC3\xAA",
 313  	 	 	 	 	 'Egrave' => "\xC3\x88",
 314  	 	 	 	 	 'egrave' => "\xC3\xA8",
 315  	 	 	 	 	 'Egrave;' => "\xC3\x88",
 316  	 	 	 	 	 'egrave;' => "\xC3\xA8",
 317  	 	 	 	 	 'empty;' => "\xE2\x88\x85",
 318  	 	 	 	 	 'emsp;' => "\xE2\x80\x83",
 319  	 	 	 	 	 'ensp;' => "\xE2\x80\x82",
 320  	 	 	 	 	 'Epsilon;' => "\xCE\x95",
 321  	 	 	 	 	 'epsilon;' => "\xCE\xB5",
 322  	 	 	 	 	 'equiv;' => "\xE2\x89\xA1",
 323  	 	 	 	 	 'Eta;' => "\xCE\x97",
 324  	 	 	 	 	 'eta;' => "\xCE\xB7",
 325  	 	 	 	 	 'ETH' => "\xC3\x90",
 326  	 	 	 	 	 'eth' => "\xC3\xB0",
 327  	 	 	 	 	 'ETH;' => "\xC3\x90",
 328  	 	 	 	 	 'eth;' => "\xC3\xB0",
 329  	 	 	 	 	 'Euml' => "\xC3\x8B",
 330  	 	 	 	 	 'euml' => "\xC3\xAB",
 331  	 	 	 	 	 'Euml;' => "\xC3\x8B",
 332  	 	 	 	 	 'euml;' => "\xC3\xAB",
 333  	 	 	 	 	 'euro;' => "\xE2\x82\xAC",
 334  	 	 	 	 	 'exist;' => "\xE2\x88\x83",
 335  	 	 	 	 	 'fnof;' => "\xC6\x92",
 336  	 	 	 	 	 'forall;' => "\xE2\x88\x80",
 337  	 	 	 	 	 'frac12' => "\xC2\xBD",
 338  	 	 	 	 	 'frac12;' => "\xC2\xBD",
 339  	 	 	 	 	 'frac14' => "\xC2\xBC",
 340  	 	 	 	 	 'frac14;' => "\xC2\xBC",
 341  	 	 	 	 	 'frac34' => "\xC2\xBE",
 342  	 	 	 	 	 'frac34;' => "\xC2\xBE",
 343  	 	 	 	 	 'frasl;' => "\xE2\x81\x84",
 344  	 	 	 	 	 'Gamma;' => "\xCE\x93",
 345  	 	 	 	 	 'gamma;' => "\xCE\xB3",
 346  	 	 	 	 	 'ge;' => "\xE2\x89\xA5",
 347  	 	 	 	 	 'GT' => "\x3E",
 348  	 	 	 	 	 'gt' => "\x3E",
 349  	 	 	 	 	 'GT;' => "\x3E",
 350  	 	 	 	 	 'gt;' => "\x3E",
 351  	 	 	 	 	 'hArr;' => "\xE2\x87\x94",
 352  	 	 	 	 	 'harr;' => "\xE2\x86\x94",
 353  	 	 	 	 	 'hearts;' => "\xE2\x99\xA5",
 354  	 	 	 	 	 'hellip;' => "\xE2\x80\xA6",
 355  	 	 	 	 	 'Iacute' => "\xC3\x8D",
 356  	 	 	 	 	 'iacute' => "\xC3\xAD",
 357  	 	 	 	 	 'Iacute;' => "\xC3\x8D",
 358  	 	 	 	 	 'iacute;' => "\xC3\xAD",
 359  	 	 	 	 	 'Icirc' => "\xC3\x8E",
 360  	 	 	 	 	 'icirc' => "\xC3\xAE",
 361  	 	 	 	 	 'Icirc;' => "\xC3\x8E",
 362  	 	 	 	 	 'icirc;' => "\xC3\xAE",
 363  	 	 	 	 	 'iexcl' => "\xC2\xA1",
 364  	 	 	 	 	 'iexcl;' => "\xC2\xA1",
 365  	 	 	 	 	 'Igrave' => "\xC3\x8C",
 366  	 	 	 	 	 'igrave' => "\xC3\xAC",
 367  	 	 	 	 	 'Igrave;' => "\xC3\x8C",
 368  	 	 	 	 	 'igrave;' => "\xC3\xAC",
 369  	 	 	 	 	 'image;' => "\xE2\x84\x91",
 370  	 	 	 	 	 'infin;' => "\xE2\x88\x9E",
 371  	 	 	 	 	 'int;' => "\xE2\x88\xAB",
 372  	 	 	 	 	 'Iota;' => "\xCE\x99",
 373  	 	 	 	 	 'iota;' => "\xCE\xB9",
 374  	 	 	 	 	 'iquest' => "\xC2\xBF",
 375  	 	 	 	 	 'iquest;' => "\xC2\xBF",
 376  	 	 	 	 	 'isin;' => "\xE2\x88\x88",
 377  	 	 	 	 	 'Iuml' => "\xC3\x8F",
 378  	 	 	 	 	 'iuml' => "\xC3\xAF",
 379  	 	 	 	 	 'Iuml;' => "\xC3\x8F",
 380  	 	 	 	 	 'iuml;' => "\xC3\xAF",
 381  	 	 	 	 	 'Kappa;' => "\xCE\x9A",
 382  	 	 	 	 	 'kappa;' => "\xCE\xBA",
 383  	 	 	 	 	 'Lambda;' => "\xCE\x9B",
 384  	 	 	 	 	 'lambda;' => "\xCE\xBB",
 385  	 	 	 	 	 'lang;' => "\xE3\x80\x88",
 386  	 	 	 	 	 'laquo' => "\xC2\xAB",
 387  	 	 	 	 	 'laquo;' => "\xC2\xAB",
 388  	 	 	 	 	 'lArr;' => "\xE2\x87\x90",
 389  	 	 	 	 	 'larr;' => "\xE2\x86\x90",
 390  	 	 	 	 	 'lceil;' => "\xE2\x8C\x88",
 391  	 	 	 	 	 'ldquo;' => "\xE2\x80\x9C",
 392  	 	 	 	 	 'le;' => "\xE2\x89\xA4",
 393  	 	 	 	 	 'lfloor;' => "\xE2\x8C\x8A",
 394  	 	 	 	 	 'lowast;' => "\xE2\x88\x97",
 395  	 	 	 	 	 'loz;' => "\xE2\x97\x8A",
 396  	 	 	 	 	 'lrm;' => "\xE2\x80\x8E",
 397  	 	 	 	 	 'lsaquo;' => "\xE2\x80\xB9",
 398  	 	 	 	 	 'lsquo;' => "\xE2\x80\x98",
 399  	 	 	 	 	 'LT' => "\x3C",
 400  	 	 	 	 	 'lt' => "\x3C",
 401  	 	 	 	 	 'LT;' => "\x3C",
 402  	 	 	 	 	 'lt;' => "\x3C",
 403  	 	 	 	 	 'macr' => "\xC2\xAF",
 404  	 	 	 	 	 'macr;' => "\xC2\xAF",
 405  	 	 	 	 	 'mdash;' => "\xE2\x80\x94",
 406  	 	 	 	 	 'micro' => "\xC2\xB5",
 407  	 	 	 	 	 'micro;' => "\xC2\xB5",
 408  	 	 	 	 	 'middot' => "\xC2\xB7",
 409  	 	 	 	 	 'middot;' => "\xC2\xB7",
 410  	 	 	 	 	 'minus;' => "\xE2\x88\x92",
 411  	 	 	 	 	 'Mu;' => "\xCE\x9C",
 412  	 	 	 	 	 'mu;' => "\xCE\xBC",
 413  	 	 	 	 	 'nabla;' => "\xE2\x88\x87",
 414  	 	 	 	 	 'nbsp' => "\xC2\xA0",
 415  	 	 	 	 	 'nbsp;' => "\xC2\xA0",
 416  	 	 	 	 	 'ndash;' => "\xE2\x80\x93",
 417  	 	 	 	 	 'ne;' => "\xE2\x89\xA0",
 418  	 	 	 	 	 'ni;' => "\xE2\x88\x8B",
 419  	 	 	 	 	 'not' => "\xC2\xAC",
 420  	 	 	 	 	 'not;' => "\xC2\xAC",
 421  	 	 	 	 	 'notin;' => "\xE2\x88\x89",
 422  	 	 	 	 	 'nsub;' => "\xE2\x8A\x84",
 423  	 	 	 	 	 'Ntilde' => "\xC3\x91",
 424  	 	 	 	 	 'ntilde' => "\xC3\xB1",
 425  	 	 	 	 	 'Ntilde;' => "\xC3\x91",
 426  	 	 	 	 	 'ntilde;' => "\xC3\xB1",
 427  	 	 	 	 	 'Nu;' => "\xCE\x9D",
 428  	 	 	 	 	 'nu;' => "\xCE\xBD",
 429  	 	 	 	 	 'Oacute' => "\xC3\x93",
 430  	 	 	 	 	 'oacute' => "\xC3\xB3",
 431  	 	 	 	 	 'Oacute;' => "\xC3\x93",
 432  	 	 	 	 	 'oacute;' => "\xC3\xB3",
 433  	 	 	 	 	 'Ocirc' => "\xC3\x94",
 434  	 	 	 	 	 'ocirc' => "\xC3\xB4",
 435  	 	 	 	 	 'Ocirc;' => "\xC3\x94",
 436  	 	 	 	 	 'ocirc;' => "\xC3\xB4",
 437  	 	 	 	 	 'OElig;' => "\xC5\x92",
 438  	 	 	 	 	 'oelig;' => "\xC5\x93",
 439  	 	 	 	 	 'Ograve' => "\xC3\x92",
 440  	 	 	 	 	 'ograve' => "\xC3\xB2",
 441  	 	 	 	 	 'Ograve;' => "\xC3\x92",
 442  	 	 	 	 	 'ograve;' => "\xC3\xB2",
 443  	 	 	 	 	 'oline;' => "\xE2\x80\xBE",
 444  	 	 	 	 	 'Omega;' => "\xCE\xA9",
 445  	 	 	 	 	 'omega;' => "\xCF\x89",
 446  	 	 	 	 	 'Omicron;' => "\xCE\x9F",
 447  	 	 	 	 	 'omicron;' => "\xCE\xBF",
 448  	 	 	 	 	 'oplus;' => "\xE2\x8A\x95",
 449  	 	 	 	 	 'or;' => "\xE2\x88\xA8",
 450  	 	 	 	 	 'ordf' => "\xC2\xAA",
 451  	 	 	 	 	 'ordf;' => "\xC2\xAA",
 452  	 	 	 	 	 'ordm' => "\xC2\xBA",
 453  	 	 	 	 	 'ordm;' => "\xC2\xBA",
 454  	 	 	 	 	 'Oslash' => "\xC3\x98",
 455  	 	 	 	 	 'oslash' => "\xC3\xB8",
 456  	 	 	 	 	 'Oslash;' => "\xC3\x98",
 457  	 	 	 	 	 'oslash;' => "\xC3\xB8",
 458  	 	 	 	 	 'Otilde' => "\xC3\x95",
 459  	 	 	 	 	 'otilde' => "\xC3\xB5",
 460  	 	 	 	 	 'Otilde;' => "\xC3\x95",
 461  	 	 	 	 	 'otilde;' => "\xC3\xB5",
 462  	 	 	 	 	 'otimes;' => "\xE2\x8A\x97",
 463  	 	 	 	 	 'Ouml' => "\xC3\x96",
 464  	 	 	 	 	 'ouml' => "\xC3\xB6",
 465  	 	 	 	 	 'Ouml;' => "\xC3\x96",
 466  	 	 	 	 	 'ouml;' => "\xC3\xB6",
 467  	 	 	 	 	 'para' => "\xC2\xB6",
 468  	 	 	 	 	 'para;' => "\xC2\xB6",
 469  	 	 	 	 	 'part;' => "\xE2\x88\x82",
 470  	 	 	 	 	 'permil;' => "\xE2\x80\xB0",
 471  	 	 	 	 	 'perp;' => "\xE2\x8A\xA5",
 472  	 	 	 	 	 'Phi;' => "\xCE\xA6",
 473  	 	 	 	 	 'phi;' => "\xCF\x86",
 474  	 	 	 	 	 'Pi;' => "\xCE\xA0",
 475  	 	 	 	 	 'pi;' => "\xCF\x80",
 476  	 	 	 	 	 'piv;' => "\xCF\x96",
 477  	 	 	 	 	 'plusmn' => "\xC2\xB1",
 478  	 	 	 	 	 'plusmn;' => "\xC2\xB1",
 479  	 	 	 	 	 'pound' => "\xC2\xA3",
 480  	 	 	 	 	 'pound;' => "\xC2\xA3",
 481  	 	 	 	 	 'Prime;' => "\xE2\x80\xB3",
 482  	 	 	 	 	 'prime;' => "\xE2\x80\xB2",
 483  	 	 	 	 	 'prod;' => "\xE2\x88\x8F",
 484  	 	 	 	 	 'prop;' => "\xE2\x88\x9D",
 485  	 	 	 	 	 'Psi;' => "\xCE\xA8",
 486  	 	 	 	 	 'psi;' => "\xCF\x88",
 487  	 	 	 	 	 'QUOT' => "\x22",
 488  	 	 	 	 	 'quot' => "\x22",
 489  	 	 	 	 	 'QUOT;' => "\x22",
 490  	 	 	 	 	 'quot;' => "\x22",
 491  	 	 	 	 	 'radic;' => "\xE2\x88\x9A",
 492  	 	 	 	 	 'rang;' => "\xE3\x80\x89",
 493  	 	 	 	 	 'raquo' => "\xC2\xBB",
 494  	 	 	 	 	 'raquo;' => "\xC2\xBB",
 495  	 	 	 	 	 'rArr;' => "\xE2\x87\x92",
 496  	 	 	 	 	 'rarr;' => "\xE2\x86\x92",
 497  	 	 	 	 	 'rceil;' => "\xE2\x8C\x89",
 498  	 	 	 	 	 'rdquo;' => "\xE2\x80\x9D",
 499  	 	 	 	 	 'real;' => "\xE2\x84\x9C",
 500  	 	 	 	 	 'REG' => "\xC2\xAE",
 501  	 	 	 	 	 'reg' => "\xC2\xAE",
 502  	 	 	 	 	 'REG;' => "\xC2\xAE",
 503  	 	 	 	 	 'reg;' => "\xC2\xAE",
 504  	 	 	 	 	 'rfloor;' => "\xE2\x8C\x8B",
 505  	 	 	 	 	 'Rho;' => "\xCE\xA1",
 506  	 	 	 	 	 'rho;' => "\xCF\x81",
 507  	 	 	 	 	 'rlm;' => "\xE2\x80\x8F",
 508  	 	 	 	 	 'rsaquo;' => "\xE2\x80\xBA",
 509  	 	 	 	 	 'rsquo;' => "\xE2\x80\x99",
 510  	 	 	 	 	 'sbquo;' => "\xE2\x80\x9A",
 511  	 	 	 	 	 'Scaron;' => "\xC5\xA0",
 512  	 	 	 	 	 'scaron;' => "\xC5\xA1",
 513  	 	 	 	 	 'sdot;' => "\xE2\x8B\x85",
 514  	 	 	 	 	 'sect' => "\xC2\xA7",
 515  	 	 	 	 	 'sect;' => "\xC2\xA7",
 516  	 	 	 	 	 'shy' => "\xC2\xAD",
 517  	 	 	 	 	 'shy;' => "\xC2\xAD",
 518  	 	 	 	 	 'Sigma;' => "\xCE\xA3",
 519  	 	 	 	 	 'sigma;' => "\xCF\x83",
 520  	 	 	 	 	 'sigmaf;' => "\xCF\x82",
 521  	 	 	 	 	 'sim;' => "\xE2\x88\xBC",
 522  	 	 	 	 	 'spades;' => "\xE2\x99\xA0",
 523  	 	 	 	 	 'sub;' => "\xE2\x8A\x82",
 524  	 	 	 	 	 'sube;' => "\xE2\x8A\x86",
 525  	 	 	 	 	 'sum;' => "\xE2\x88\x91",
 526  	 	 	 	 	 'sup;' => "\xE2\x8A\x83",
 527  	 	 	 	 	 'sup1' => "\xC2\xB9",
 528  	 	 	 	 	 'sup1;' => "\xC2\xB9",
 529  	 	 	 	 	 'sup2' => "\xC2\xB2",
 530  	 	 	 	 	 'sup2;' => "\xC2\xB2",
 531  	 	 	 	 	 'sup3' => "\xC2\xB3",
 532  	 	 	 	 	 'sup3;' => "\xC2\xB3",
 533  	 	 	 	 	 'supe;' => "\xE2\x8A\x87",
 534  	 	 	 	 	 'szlig' => "\xC3\x9F",
 535  	 	 	 	 	 'szlig;' => "\xC3\x9F",
 536  	 	 	 	 	 'Tau;' => "\xCE\xA4",
 537  	 	 	 	 	 'tau;' => "\xCF\x84",
 538  	 	 	 	 	 'there4;' => "\xE2\x88\xB4",
 539  	 	 	 	 	 'Theta;' => "\xCE\x98",
 540  	 	 	 	 	 'theta;' => "\xCE\xB8",
 541  	 	 	 	 	 'thetasym;' => "\xCF\x91",
 542  	 	 	 	 	 'thinsp;' => "\xE2\x80\x89",
 543  	 	 	 	 	 'THORN' => "\xC3\x9E",
 544  	 	 	 	 	 'thorn' => "\xC3\xBE",
 545  	 	 	 	 	 'THORN;' => "\xC3\x9E",
 546  	 	 	 	 	 'thorn;' => "\xC3\xBE",
 547  	 	 	 	 	 'tilde;' => "\xCB\x9C",
 548  	 	 	 	 	 'times' => "\xC3\x97",
 549  	 	 	 	 	 'times;' => "\xC3\x97",
 550  	 	 	 	 	 'TRADE;' => "\xE2\x84\xA2",
 551  	 	 	 	 	 'trade;' => "\xE2\x84\xA2",
 552  	 	 	 	 	 'Uacute' => "\xC3\x9A",
 553  	 	 	 	 	 'uacute' => "\xC3\xBA",
 554  	 	 	 	 	 'Uacute;' => "\xC3\x9A",
 555  	 	 	 	 	 'uacute;' => "\xC3\xBA",
 556  	 	 	 	 	 'uArr;' => "\xE2\x87\x91",
 557  	 	 	 	 	 'uarr;' => "\xE2\x86\x91",
 558  	 	 	 	 	 'Ucirc' => "\xC3\x9B",
 559  	 	 	 	 	 'ucirc' => "\xC3\xBB",
 560  	 	 	 	 	 'Ucirc;' => "\xC3\x9B",
 561  	 	 	 	 	 'ucirc;' => "\xC3\xBB",
 562  	 	 	 	 	 'Ugrave' => "\xC3\x99",
 563  	 	 	 	 	 'ugrave' => "\xC3\xB9",
 564  	 	 	 	 	 'Ugrave;' => "\xC3\x99",
 565  	 	 	 	 	 'ugrave;' => "\xC3\xB9",
 566  	 	 	 	 	 'uml' => "\xC2\xA8",
 567  	 	 	 	 	 'uml;' => "\xC2\xA8",
 568  	 	 	 	 	 'upsih;' => "\xCF\x92",
 569  	 	 	 	 	 'Upsilon;' => "\xCE\xA5",
 570  	 	 	 	 	 'upsilon;' => "\xCF\x85",
 571  	 	 	 	 	 'Uuml' => "\xC3\x9C",
 572  	 	 	 	 	 'uuml' => "\xC3\xBC",
 573  	 	 	 	 	 'Uuml;' => "\xC3\x9C",
 574  	 	 	 	 	 'uuml;' => "\xC3\xBC",
 575  	 	 	 	 	 'weierp;' => "\xE2\x84\x98",
 576  	 	 	 	 	 'Xi;' => "\xCE\x9E",
 577  	 	 	 	 	 'xi;' => "\xCE\xBE",
 578  	 	 	 	 	 'Yacute' => "\xC3\x9D",
 579  	 	 	 	 	 'yacute' => "\xC3\xBD",
 580  	 	 	 	 	 'Yacute;' => "\xC3\x9D",
 581  	 	 	 	 	 'yacute;' => "\xC3\xBD",
 582  	 	 	 	 	 'yen' => "\xC2\xA5",
 583  	 	 	 	 	 'yen;' => "\xC2\xA5",
 584  	 	 	 	 	 'yuml' => "\xC3\xBF",
 585  	 	 	 	 	 'Yuml;' => "\xC5\xB8",
 586  	 	 	 	 	 'yuml;' => "\xC3\xBF",
 587  	 	 	 	 	 'Zeta;' => "\xCE\x96",
 588  	 	 	 	 	 'zeta;' => "\xCE\xB6",
 589  	 	 	 	 	 'zwj;' => "\xE2\x80\x8D",
 590  	 	 	 	 	 'zwnj;' => "\xE2\x80\x8C"
 591  	 	 	 	 );
 592  
 593  	 	 	 	 for ($i = 0, $match = null; $i < 9 && $this->consume() !== false; $i++)
 594  	 	 	 	 {
 595  	 	 	 	 	 $consumed = substr($this->consumed, 1);
 596  	 	 	 	 	 if (isset($entities[$consumed]))
 597  	 	 	 	 	 {
 598  	 	 	 	 	 	 $match = $consumed;
 599  	 	 	 	 	 }
 600  	 	 	 	 }
 601  
 602  	 	 	 	 if ($match !== null)
 603  	 	 	 	 {
 604   	 	 	 	 	 $this->data = substr_replace($this->data, $entities[$match], $this->position - strlen($consumed) - 1, strlen($match) + 1);
 605  	 	 	 	 	 $this->position += strlen($entities[$match]) - strlen($consumed) - 1;
 606  	 	 	 	 }
 607  	 	 	 	 break;
 608  	 	 }
 609  	 }
 610  }