PKPString::getHTMLEntities PHP Method

getHTMLEntities() static public method

Return an associative array of named->numeric HTML entities Required to support HTML functions without objects in PHP4/PHP5 From php.net: function.get-html-translation-table.php
static public getHTMLEntities ( ) : string
return string
    static function getHTMLEntities()
    {
        // define the conversion table
        $html_entities = array("Á" => "Á", "á" => "á", "Â" => "Â", "â" => "â", "´" => "´", "Æ" => "Æ", "æ" => "æ", "À" => "À", "à" => "à", "ℵ" => "ℵ", "Α" => "Α", "α" => "α", "&" => "&", "∧" => "∧", "∠" => "∠", "'" => "'", "Å" => "Å", "å" => "å", "≈" => "≈", "Ã" => "Ã", "ã" => "ã", "Ä" => "Ä", "ä" => "ä", "„" => "„", "Β" => "Β", "β" => "β", "¦" => "¦", "•" => "•", "∩" => "∩", "Ç" => "Ç", "ç" => "ç", "¸" => "¸", "¢" => "¢", "Χ" => "Χ", "χ" => "χ", "ˆ" => "^", "♣" => "♣", "≅" => "≅", "©" => "©", "↵" => "↵", "∪" => "∪", "¤" => "¤", "†" => "†", "‡" => "‡", "↓" => "↓", "⇓" => "⇓", "°" => "°", "Δ" => "Δ", "δ" => "δ", "♦" => "♦", "÷" => "÷", "É" => "É", "é" => "é", "Ê" => "Ê", "ê" => "ê", "È" => "È", "è" => "è", "∅" => "∅", " " => " ", " " => " ", "Ε" => "Ε", "ε" => "ε", "≡" => "≡", "Η" => "Η", "η" => "η", "Ð" => "Ð", "ð" => "ð", "Ë" => "Ë", "ë" => "ë", "€" => "€", "∃" => "∃", "ƒ" => "ƒ", "∀" => "∀", "½" => "½", "¼" => "¼", "¾" => "¾", "⁄" => "⁄", "Γ" => "Γ", "γ" => "γ", "≥" => "≥", ">" => ">", "↔" => "↔", "⇔" => "⇔", "♥" => "♥", "…" => "…", "Í" => "Í", "í" => "í", "Î" => "Î", "î" => "î", "¡" => "¡", "Ì" => "Ì", "ì" => "ì", "ℑ" => "ℑ", "∞" => "∞", "∫" => "∫", "Ι" => "Ι", "ι" => "ι", "¿" => "¿", "∈" => "∈", "Ï" => "Ï", "ï" => "ï", "Κ" => "Κ", "κ" => "κ", "Λ" => "Λ", "λ" => "λ", "⟨" => "〈", "«" => "«", "←" => "←", "⇐" => "⇐", "⌈" => "⌈", "“" => "“", "≤" => "≤", "⌊" => "⌊", "∗" => "∗", "◊" => "◊", "‎" => "‎", "‹" => "‹", "‘" => "‘", "<" => "<", "¯" => "¯", "—" => "—", "µ" => "µ", "·" => "·", "−" => "-", "Μ" => "Μ", "μ" => "μ", "∇" => "∇", " " => " ", "–" => "–", "≠" => "≠", "∋" => "∋", "¬" => "¬", "∉" => "∉", "⊄" => "⊄", "Ñ" => "Ñ", "ñ" => "ñ", "Ν" => "Ν", "ν" => "ν", "Ó" => "Ó", "ó" => "ó", "Ô" => "Ô", "ô" => "ô", "Œ" => "Œ", "œ" => "œ", "Ò" => "Ò", "ò" => "ò", "‾" => "‾", "Ω" => "Ω", "ω" => "ω", "Ο" => "Ο", "ο" => "ο", "⊕" => "⊕", "∨" => "∨", "ª" => "ª", "º" => "º", "Ø" => "Ø", "ø" => "ø", "Õ" => "Õ", "õ" => "õ", "⊗" => "⊗", "Ö" => "Ö", "ö" => "ö", "¶" => "¶", "∂" => "∂", "‰" => "‰", "⊥" => "⊥", "Φ" => "Φ", "φ" => "φ", "Π" => "Π", "π" => "π", "ϖ" => "ϖ", "±" => "±", "£" => "£", "′" => "′", "″" => "″", "∏" => "∏", "∝" => "∝", "Ψ" => "Ψ", "ψ" => "ψ", """ => """, "√" => "√", "⟩" => "〉", "»" => "»", "→" => "→", "⇒" => "⇒", "⌉" => "⌉", "”" => "”", "ℜ" => "ℜ", "®" => "®", "⌋" => "⌋", "Ρ" => "Ρ", "ρ" => "ρ", "‏" => "‏", "›" => "›", "’" => "’", "‚" => "‚", "Š" => "Š", "š" => "š", "⋅" => "⋅", "§" => "§", "­" => "­", "Σ" => "Σ", "σ" => "σ", "ς" => "ς", "∼" => "∼", "♠" => "♠", "⊂" => "⊂", "⊆" => "⊆", "∑" => "∑", "¹" => "¹", "²" => "²", "³" => "³", "⊃" => "⊃", "⊇" => "⊇", "ß" => "ß", "Τ" => "Τ", "τ" => "τ", "∴" => "∴", "Θ" => "Θ", "θ" => "θ", "ϑ" => "ϑ", " " => " ", "Þ" => "Þ", "þ" => "þ", "˜" => "~", "×" => "×", "™" => "™", "Ú" => "Ú", "ú" => "ú", "↑" => "↑", "⇑" => "⇑", "Û" => "Û", "û" => "û", "Ù" => "Ù", "ù" => "ù", "¨" => "¨", "ϒ" => "ϒ", "Υ" => "Υ", "υ" => "υ", "Ü" => "Ü", "ü" => "ü", "℘" => "℘", "Ξ" => "Ξ", "ξ" => "ξ", "Ý" => "Ý", "ý" => "ý", "¥" => "¥", "ÿ" => "ÿ", "Ÿ" => "Ÿ", "Ζ" => "Ζ", "ζ" => "ζ", "‍" => "‍", "‌" => "‌");
        return $html_entities;
    }

Usage Example

 /**
  * Parse an XML file using the specified handler.
  * If no handler has been specified, XMLParserDOMHandler is used by default, returning a tree structure representing the document.
  * @param $file string full path to the XML file
  * @param $dataCallback mixed Optional callback for data handling: function dataCallback($operation, $wrapper, $data = null)
  * @return object actual return type depends on the handler
  */
 function &parse($file, $dataCallback = null)
 {
     $parser =& $this->createParser();
     if (!isset($this->handler)) {
         // Use default handler for parsing
         $handler = new XMLParserDOMHandler();
         $this->setHandler($handler);
     }
     xml_set_object($parser, $this->handler);
     xml_set_element_handler($parser, "startElement", "endElement");
     xml_set_character_data_handler($parser, "characterData");
     import('lib.pkp.classes.file.FileWrapper');
     $wrapper =& FileWrapper::wrapper($file);
     // Handle responses of various types
     while (true) {
         $newWrapper = $wrapper->open();
         if (is_object($newWrapper)) {
             // Follow a redirect
             unset($wrapper);
             $wrapper =& $newWrapper;
             unset($newWrapper);
         } elseif (!$newWrapper) {
             // Could not open resource -- error
             $returner = false;
             return $returner;
         } else {
             // OK, we've found the end result
             break;
         }
     }
     if (!$wrapper) {
         $result = false;
         return $result;
     }
     if ($dataCallback) {
         call_user_func($dataCallback, 'open', $wrapper);
     }
     while (!$wrapper->eof() && ($data = $wrapper->read()) !== false) {
         // if the string contains non-UTF8 characters, convert it to UTF-8 for parsing
         if (Config::getVar('i18n', 'charset_normalization') == 'On' && !PKPString::utf8_compliant($data)) {
             $utf8_last = PKPString::substr($data, PKPString::strlen($data) - 1);
             // if the string ends in a "bad" UTF-8 character, maybe it's truncated
             while (!$wrapper->eof() && PKPString::utf8_bad_find($utf8_last) === 0) {
                 // read another chunk of data
                 $data .= $wrapper->read();
                 $utf8_last = PKPString::substr($data, PKPString::strlen($data) - 1);
             }
             $data = PKPString::utf8_normalize($data);
             // strip any invalid UTF-8 sequences
             $data = PKPString::utf8_bad_strip($data);
             // convert named entities to numeric entities
             $data = strtr($data, PKPString::getHTMLEntities());
         }
         // strip any invalid ASCII control characters
         $data = PKPString::utf8_strip_ascii_ctrl($data);
         if ($dataCallback) {
             call_user_func($dataCallback, 'parse', $wrapper, $data);
         }
         if (!xml_parse($parser, $data, $wrapper->eof())) {
             $this->addError(xml_error_string(xml_get_error_code($parser)));
         }
     }
     if ($dataCallback) {
         call_user_func($dataCallback, 'close', $wrapper);
     }
     $wrapper->close();
     $result = $this->handler->getResult();
     $this->destroyParser($parser);
     if (isset($handler)) {
         $handler->destroy();
     }
     return $result;
 }