OSDN Git Service

Merge branch 'skinnable-master'
[nucleus-jp/nucleus-next.git] / nucleus / libs / ENTITY.php
index 524f748..413d324 100644 (file)
-<?php\r
-\r
-class Entity\r
-{\r
-       /**\r
-        * Entity::hen\r
-        * htmlentities wrapper\r
-        * \r
-        * @static\r
-        * @access public\r
-        * @param       string  $string target string\r
-        * @param       string  $quotation      quotation mode. please refer to the argument of PHP built-in htmlentities\r
-        * @return      string  escaped string\r
-        */\r
-       static public function hen($string, $quotation=ENT_QUOTES)\r
-       {\r
-               /*\r
-                * we can use 'double_encode' flag instead of this when dropping supports for PHP 5.2.2 or lower\r
-                */\r
-               $string = html_entity_decode($string, $quotation, i18n::get_current_charset());\r
-               return (string) htmlentities($string, $quotation, i18n::get_current_charset());\r
-       }\r
-       \r
-       /**\r
-        * Entity::hsc\r
-        * htmlspecialchars wrapper\r
-        * \r
-        * NOTE: htmlspecialchars_decode() is ASCII-to-ACII conversion\r
-        *  and its target string consists of several letters.\r
-        *   There are no problems.\r
-        * \r
-        * @static\r
-        * @access public\r
-        * @param       string  $string target string\r
-        * @param       string  $quotation      quotation mode. please refer to the argument of PHP built-in htmlspecialchars\r
-        * @return      string  escaped string\r
-        * \r
-        */\r
-       static public function hsc($string, $quotation=ENT_QUOTES)\r
-       {\r
-               /*\r
-                * we can use 'double_encode' flag instead of this when dropping supports for PHP 5.2.2 or lower\r
-                */\r
-               $string = htmlspecialchars_decode($string, $quotation);\r
-               return (string) htmlspecialchars($string, $quotation, i18n::get_current_charset());\r
-       }\r
-       \r
-       /**\r
-        * Entity::strip_tags()\r
-        * Strip HTML tags from a string\r
-        * \r
-        * This function is a bit more intelligent than a regular call to strip_tags(),\r
-        * because it also deletes the contents of certain tags and cleans up any\r
-        * unneeded whitespace.\r
-        * \r
-        * @static\r
-        * @param       String  $string target string\r
-        * @return      String  string with stripped tags\r
-        */\r
-       static public function strip_tags($string)\r
-       {\r
-               $string = preg_replace("#<del[^>]*>.+<\/del[^>]*>#isU", '', $string);\r
-               $string = preg_replace("#<script[^>]*>.+<\/script[^>]*>#isU", '', $string);\r
-               $string = preg_replace("#<style[^>]*>.+<\/style[^>]*>#isU", '', $string);\r
-               $string = preg_replace('#>#', '> ', $string);\r
-               $string = preg_replace('#<#', ' <', $string);\r
-               $string = strip_tags($string);\r
-               $string = preg_replace("#\s+#", " ", $string);\r
-               $string = trim($string);\r
-               return $string;\r
-       }\r
-       \r
-       /**\r
-        * shortens a text string to maxlength.\r
-        * $suffix is what needs to be added at the end (end length is <= $maxlength)\r
-        *\r
-        * The purpose is to limit the width of string for rendered screen in web browser.\r
-        * So it depends on style sheet, browser's rendering scheme, client's system font.\r
-        *\r
-        * NOTE: In general, non-Latin font such as Japanese, Chinese, Cyrillic have two times as width as Latin fonts,\r
-        *  but this is not always correct, for example, rendered by proportional font.\r
-        *\r
-        * @static\r
-        * @param string $escaped_string target string\r
-        * @param integer $maxlength maximum length of return string which includes suffix\r
-        * @param string $suffix added in the end of shortened-string\r
-        * @return string\r
-        */\r
-       static public function shorten($string, $maxlength, $suffix)\r
-       {\r
-               static $flag;\r
-               \r
-               $decoded_entities_pcre = array();\r
-               $encoded_entities = array();\r
-               \r
-               /* 1. store html entities */\r
-               preg_match('#&[^&]+?;#', $string, $encoded_entities);\r
-               if ( !$encoded_entities )\r
-               {\r
-                       $flag = FALSE;\r
-               }\r
-               else\r
-               {\r
-                       $flag = TRUE;\r
-               }\r
-               if ( $flag )\r
-               {\r
-                       foreach ( $encoded_entities as $encoded_entity )\r
-                       {\r
-                               $decoded_entities_pcre[] = '#' . html_entity_decode($encoded_entity, ENT_QUOTES, i18n::get_current_charset()) . '#';\r
-                       }\r
-               }\r
-               \r
-               /* 2. decode string */\r
-               $string = html_entity_decode($string, ENT_QUOTES, i18n::get_current_charset());\r
-               \r
-               /* 3. shorten string and add suffix if string length is longer */\r
-               if ( i18n::strlen($string) > $maxlength - i18n::strlen($suffix) )\r
-               {\r
-                       $string = i18n::substr($string, 0, $maxlength - i18n::strlen($suffix) );\r
-                       $string .= $suffix;\r
-               }\r
-               \r
-               /* 4. recover entities */\r
-               if ( $flag )\r
-               {\r
-                       $string = preg_replace($decoded_entities_pcre, $encoded_entities, $string);\r
-               }\r
-               \r
-               return $string;\r
-       }\r
-       \r
-       /**\r
-        * Entity::highlight()\r
-        * highlights a specific query in a given HTML text (not within HTML tags)\r
-        * \r
-        * @static\r
-        * @param       string $text text to be highlighted\r
-        * @param       string $expression regular expression to be matched (can be an array of expressions as well)\r
-        * @param       string $highlight highlight to be used (use \\0 to indicate the matched expression)\r
-        * @return      string\r
-        */\r
-       static public function highlight($text, $expression, $highlight)\r
-       {\r
-               if ( !$highlight || !$expression )\r
-               {\r
-                       return $text;\r
-               }\r
-               \r
-               if ( is_array($expression) && (count($expression) == 0) )\r
-               {\r
-                       return $text;\r
-               }\r
-               \r
-               $text = "<!--h-->{$text}";\r
-               preg_match_all('#(<[^>]+>)([^<>]*)#', $text, $matches);\r
-               $result = '';\r
-               $count = count($matches[2]);\r
-               \r
-               for ( $i = 0; $i < $count; $i++ )\r
-               {\r
-                       if ( $i != 0 )\r
-                       {\r
-                               $result .= $matches[1][$i];\r
-                       }\r
-                       \r
-                       if ( is_array($expression) )\r
-                       {\r
-                               foreach ( $expression as $regex )\r
-                               {\r
-                                               $matches[2][$i] = preg_replace("#{$regex}#i", $highlight, $matches[2][$i]);\r
-                               }\r
-                               $result .= $matches[2][$i];\r
-                       }\r
-                       else\r
-                       {\r
-                               $result .= preg_replace("#{$expression}#i", $highlight, $matches[2][$i]);\r
-                       }\r
-               }\r
-               return $result;\r
-       }\r
-       \r
-       /**\r
-        * Entity::anchor_footnoting()\r
-        * change strings with footnoticing generated from anchor elements\r
-        * \r
-        * @static\r
-        * @param       String  $string strings which includes html elements\r
-        * @return      String  string with footnotes\r
-        */\r
-       static public function anchor_footnoting($string)\r
-       {\r
-               /* 1. detect anchor elements */\r
-               $anchors = array();\r
-               if ( !preg_match_all("#<a[^>]*href=[\"\']([^\"^']*)[\"\'][^>]*>([^<]*)<\/a>#i", $subject, $anchors) )\r
-               {\r
-                       return $string;\r
-               }\r
-               \r
-               /* 2. add footnotes */\r
-               $string .= "\n\n";\r
-               $count = 1;\r
-               foreach ( $anchors as $anchor )\r
-               {\r
-                       preg_replace("#{$anchor[0]}#", "{$anchor[2]} [{$count}] ", $subject);\r
-                       $subject .= "[{$count}] {$anchor[1]}\n";\r
-                       $count++;\r
-               }\r
-               \r
-               return strip_tags($ascii);\r
-       }\r
-       \r
-       /*\r
-        * NOTE: Obsoleted functions\r
-        */\r
-       \r
-       /**\r
-        * Entity::named_to_numeric()\r
-        * \r
-        * @deprecated\r
-        * @param String $string\r
-        */\r
-       function named_to_numeric ($string)\r
-       {\r
-               $string = preg_replace('/(&[0-9A-Za-z]+)(;?\=?|([^A-Za-z0-9\;\:\.\-\_]))/e', "Entity::_named('\\1', '\\2') . '\\3'", $string);\r
-               return $string;\r
-       }\r
-       \r
-       /**\r
-        * Entity::named_to_numeric()\r
-        * \r
-        * @deprecated\r
-        * @param String $string\r
-        */\r
-       function normalize_numeric ($string) {\r
-               $string = preg_replace('/&#([0-9]+)(;)?/e', "'&#x'.dechex('\\1').';'", $string);\r
-               $string = preg_replace('/&#[Xx](0)*([0-9A-Fa-f]+)(;?|([^A-Za-z0-9\;\:\.\-\_]))/e', "'&#x' . strtoupper('\\2') . ';\\4'", $string);\r
-               $string = strtr($string, self::$entities['Windows-1252']);\r
-               return $string;\r
-       }\r
-       \r
-       /**\r
-        * Entity::numeric_to_utf8()\r
-        * \r
-        * @deprecated\r
-        * @param String $string\r
-        */\r
-       function numeric_to_utf8 ($string) {\r
-               $string = preg_replace('/&#([0-9]+)(;)?/e', "'&#x'.dechex('\\1').';'", $string);\r
-               $string = preg_replace('/&#[Xx](0)*([0-9A-Fa-f]+)(;?|([^A-Za-z0-9\;\:\.\-\_]))/e', "'&#x' . strtoupper('\\2') . ';\\4'", $string);\r
-               $string = preg_replace('/&#x([0-9A-Fa-f]+);/e', "Entity::_hex_to_utf8('\\1')", $string);                \r
-               return $string;         \r
-       }\r
-       \r
-       /**\r
-        * Entity::numeric_to_named()\r
-        * convert decimal and hexadecimal numeric character references into named character references\r
-        * \r
-        * @deprecated\r
-        * @param String $string\r
-        */\r
-       function numeric_to_named ($string)\r
-       {\r
-               $string = preg_replace('/&#[Xx]([0-9A-Fa-f]+)/e', "'&#'.hexdec('\\1')", $string);\r
-               $string = strtr($string, array_flip(self::$entities['named_to_numeric']));\r
-               return $string; \r
-       }\r
-       \r
-       /**\r
-        * Entity::specialchars()\r
-        * convert HTML entities to named character reference\r
-        * \r
-        * @deprecated\r
-        * @param String $string\r
-        */\r
-       function specialchars ($string, $type = 'xml')\r
-       {\r
-               $specialchars = array(\r
-                       '"'             => '&quot;',\r
-                       '&'             => '&amp;',\r
-                       '<'             => '&lt;',\r
-                       '>'             => '&gt;'\r
-               );\r
-               if ( $type != 'xml' )\r
-               {\r
-                       $specialchars["'"] = '&#39;';\r
-               }\r
-               else\r
-               {\r
-                       $specialchars["'"] = '&apos;';\r
-               }\r
-               \r
-               $string = preg_replace('/&(#?[Xx]?[0-9A-Za-z]+);/', "[[[ENTITY:\\1]]]", $string);\r
-               $string = strtr($string, $specialchars);\r
-               $string = preg_replace('/\[\[\[ENTITY\:([^\]]+)\]\]\]/', "&\\1;", $string);             \r
-               return $string;\r
-       }\r
-       \r
-       /**\r
-        * Entity::_hex_to_utf8()\r
-        * convert decimal numeric character references to hexadecimal numeric character references\r
-        * \r
-        * @deprecated\r
-        * @param String $string\r
-        */\r
-       function _hex_to_utf8($s)\r
-       {\r
-               $c = hexdec($s);\r
-               \r
-               if ( $c < 0x80 )\r
-               {\r
-                       $str = chr($c);\r
-               }\r
-               else if ( $c < 0x800 )\r
-               {\r
-                       $str = chr(0xC0 | $c>>6) . chr(0x80 | $c & 0x3F);\r
-               }\r
-               else if ( $c < 0x10000 )\r
-               {\r
-                       $str = chr(0xE0 | $c>>12) . chr(0x80 | $c>>6 & 0x3F) . chr(0x80 | $c & 0x3F);\r
-               }\r
-               else if ( $c < 0x200000 )\r
-               {\r
-                       $str = chr(0xF0 | $c>>18) . chr(0x80 | $c>>12 & 0x3F) . chr(0x80 | $c>>6 & 0x3F) . chr(0x80 | $c & 0x3F);\r
-               }\r
-               return $str;\r
-       }\r
-       \r
-       /**\r
-        * Entity::_named()\r
-        * convert entities to named character reference\r
-        * \r
-        * @deprecated\r
-        * @param String $string\r
-        * @param       String  $extra\r
-        * @return      \r
-        */\r
-       function _named($entity, $extra)\r
-       {\r
-               if ( $extra == '=' )\r
-               {\r
-                       return $entity . '=';\r
-               }\r
-               \r
-               $length = i18n::strlen($entity);\r
-               \r
-               while ( $length > 0 )\r
-               {\r
-                       $check = i18n::substr($entity, 0, $length);\r
-                       if ( array_key_exists($check, self::$entities['named_to_numeric']) )\r
-                       {\r
-                               return self::$entities['named_to_numeric'][$check] . ';' . i18n::substr($entity, $length);\r
-                       }\r
-                       $length--;\r
-               }\r
-               \r
-               if ( $extra != ';' )\r
-               {\r
-                       return $entity;\r
-               }\r
-               else\r
-               {\r
-                       return "{$entity};";\r
-               }\r
-       }\r
-       \r
-       /**\r
-        * ENTITIY::$entities\r
-        * \r
-        * HTML 4.01 Specification\r
-        * @link        http://www.w3.org/TR/html4/sgml/entities.html\r
-        * @see 24 Character entity references in HTML 4\r
-        * \r
-        * XHTML™ 1.0 The Extensible HyperText Markup Language (Second Edition)\r
-        *  A Reformulation of HTML 4 in XML 1.0\r
-        * @link        http://www.w3.org/TR/xhtml1/\r
-        * @see 4.12. Entity references as hex values\r
-        * @see C.16. The Named Character Reference &apos;\r
-        * \r
-        * @static\r
-        * @deprecated\r
-        */\r
-       static private $entities = array (\r
-               'named_to_numeric' => array (\r
-                       '&nbsp' =>      '&#x00A0',\r
-                       '&iexcl'        =>      '&#x00A1',\r
-                       '&cent' =>      '&#x00A2',\r
-                       '&pound'        =>      '&#x00A3',\r
-                       '&curren'       =>      '&#x00A4',\r
-                       '&yen'          =>      '&#x00A5',\r
-                       '&brvbar'       =>      '&#x00A6',\r
-                       '&sect' =>      '&#x00A7',\r
-                       '&uml'          =>      '&#x00A8',\r
-                       '&copy' =>      '&#x00A9',\r
-                       '&ordf' =>      '&#x00AA',\r
-                       '&laquo'        =>      '&#x00AB',\r
-                       '&not'          =>      '&#x00AC',\r
-                       '&shy'          =>      '&#x00AD',\r
-                       '&reg'          =>      '&#x00AE',\r
-                       '&macr' =>      '&#x00AF',\r
-                       '&deg'          =>      '&#x00B0',\r
-                       '&plusmn'       =>      '&#x00B1',\r
-                       '&sup2' =>      '&#x00B2',\r
-                       '&sup3' =>      '&#x00B3',\r
-                       '&acute'        =>      '&#x00B4',\r
-                       '&micro'        =>      '&#x00B5',\r
-                       '&para' =>      '&#x00B6',\r
-                       '&middot'       =>      '&#x00B7',\r
-                       '&cedil'        =>      '&#x00B8',\r
-                       '&sup1' =>      '&#x00B9',\r
-                       '&ordm' =>      '&#x00BA',\r
-                       '&raquo'        =>      '&#x00BB',\r
-                       '&frac14'       =>      '&#x00BC',\r
-                       '&frac12'       =>      '&#x00BD',\r
-                       '&frac34'       =>      '&#x00BE',\r
-                       '&iquest'       =>      '&#x00BF',\r
-                       '&Agrave'       =>      '&#x00C0',\r
-                       '&Aacute'       =>      '&#x00C1',\r
-                       '&Acirc'        =>      '&#x00C2',\r
-                       '&Atilde'       =>      '&#x00C3',\r
-                       '&Auml' =>      '&#x00C4',\r
-                       '&Aring'        =>      '&#x00C5',\r
-                       '&AElig'        =>      '&#x00C6',\r
-                       '&Ccedil'       =>      '&#x00C7',\r
-                       '&Egrave'       =>      '&#x00C8',\r
-                       '&Eacute'       =>      '&#x00C9',\r
-                       '&Ecirc'        =>      '&#x00CA',\r
-                       '&Euml' =>      '&#x00CB',\r
-                       '&Igrave'       =>      '&#x00CC',\r
-                       '&Iacute'       =>      '&#x00CD',\r
-                       '&Icirc'        =>      '&#x00CE',\r
-                       '&Iuml' =>      '&#x00CF',\r
-                       '&ETH'          =>      '&#x00D0',\r
-                       '&Ntilde'       =>      '&#x00D1',\r
-                       '&Ograve'       =>      '&#x00D2',\r
-                       '&Oacute'       =>      '&#x00D3',\r
-                       '&Ocirc'        =>      '&#x00D4',\r
-                       '&Otilde'       =>      '&#x00D5',\r
-                       '&Ouml' =>      '&#x00D6',\r
-                       '&times'        =>      '&#x00D7',\r
-                       '&Oslash'       =>      '&#x00D8',\r
-                       '&Ugrave'       =>      '&#x00D9',\r
-                       '&Uacute'       =>      '&#x00DA',\r
-                       '&Ucirc'        =>      '&#x00DB',\r
-                       '&Uuml' =>      '&#x00DC',\r
-                       '&Yacute'       =>      '&#x00DD',\r
-                       '&THORN'        =>      '&#x00DE',\r
-                       '&szlig'        =>      '&#x00DF',\r
-                       '&agrave'       =>      '&#x00E0',\r
-                       '&aacute'       =>      '&#x00E1',\r
-                       '&acirc'        =>      '&#x00E2',\r
-                       '&atilde'       =>      '&#x00E3',\r
-                       '&auml' =>      '&#x00E4',\r
-                       '&aring'        =>      '&#x00E5',\r
-                       '&aelig'        =>      '&#x00E6',\r
-                       '&ccedil'       =>      '&#x00E7',\r
-                       '&egrave'       =>      '&#x00E8',\r
-                       '&eacute'       =>      '&#x00E9',\r
-                       '&ecirc'        =>      '&#x00EA',\r
-                       '&euml' =>      '&#x00EB',\r
-                       '&igrave'       =>      '&#x00EC',\r
-                       '&iacute'       =>      '&#x00ED',\r
-                       '&icirc'        =>      '&#x00EE',\r
-                       '&iuml' =>      '&#x00EF',\r
-                       '&eth'          =>      '&#x00F0',\r
-                       '&ntilde'       =>      '&#x00F1',\r
-                       '&ograve'       =>      '&#x00F2',\r
-                       '&oacute'       =>      '&#x00F3',\r
-                       '&ocirc'        =>      '&#x00F4',\r
-                       '&otilde'       =>      '&#x00F5',\r
-                       '&ouml' =>      '&#x00F6',\r
-                       '&divide'       =>      '&#x00F7',\r
-                       '&oslash'       =>      '&#x00F8',\r
-                       '&ugrave'       =>      '&#x00F9',\r
-                       '&uacute'       =>      '&#x00FA',\r
-                       '&ucirc'        =>      '&#x00FB',\r
-                       '&uuml' =>      '&#x00FC',\r
-                       '&yacute'       =>      '&#x00FD',\r
-                       '&thorn'        =>      '&#x00FE',\r
-                       '&yuml' =>      '&#x00FF',\r
-                       '&OElig'        =>      '&#x0152',\r
-                       '&oelig'        =>      '&#x00E5',\r
-                       '&Scaron'       =>      '&#x0160',\r
-                       '&scaron'       =>      '&#x0161',\r
-                       '&Yuml' =>      '&#x0178',\r
-                       '&circ' =>      '&#x02C6',\r
-                       '&tilde'        =>      '&#x02DC',\r
-                       '&esnp' =>      '&#x2002',\r
-                       '&emsp' =>      '&#x2003',\r
-                       '&thinsp'       =>      '&#x2009',\r
-                       '&zwnj' =>      '&#x200C',\r
-                       '&zwj'          =>      '&#x200D',\r
-                       '&lrm'          =>      '&#x200E',\r
-                       '&rlm'          =>      '&#x200F',\r
-                       '&ndash'        =>      '&#x2013',\r
-                       '&mdash'        =>      '&#x2014',\r
-                       '&lsquo'        =>      '&#x2018',\r
-                       '&rsquo'        =>      '&#x2019',\r
-                       '&sbquo'        =>      '&#x201A',\r
-                       '&ldquo'        =>      '&#x201C',\r
-                       '&rdquo'        =>      '&#x201D',\r
-                       '&bdquo'        =>      '&#x201E',\r
-                       '&dagger'       =>      '&#x2020',\r
-                       '&Dagger'       =>      '&#x2021',\r
-                       '&permil'       =>      '&#x2030',\r
-                       '&lsaquo'       =>      '&#x2039',\r
-                       '&rsaquo'       =>      '&#x203A',\r
-                       '&euro' =>      '&#x20AC',\r
-                       '&fnof' =>      '&#x0192',\r
-                       '&Alpha'        =>      '&#x0391',\r
-                       '&Beta' =>      '&#x0392',\r
-                       '&Gamma'        =>      '&#x0393',\r
-                       '&Delta'        =>      '&#x0394',\r
-                       '&Epsilon'      =>      '&#x0395',\r
-                       '&Zeta' =>      '&#x0396',\r
-                       '&Eta'          =>      '&#x0397',\r
-                       '&Theta'        =>      '&#x0398',\r
-                       '&Iota' =>      '&#x0399',\r
-                       '&Kappa'        =>      '&#x039A',\r
-                       '&Lambda'       =>      '&#x039B',\r
-                       '&Mu'           =>      '&#x039C',\r
-                       '&Nu'           =>      '&#x039D',\r
-                       '&Xi'           =>      '&#x039E',\r
-                       '&Omicron'      =>      '&#x039F',\r
-                       '&Pi'           =>      '&#x03A0',\r
-                       '&Rho'          =>      '&#x03A1',\r
-                       '&Sigma'        =>      '&#x03A3',\r
-                       '&Tau'          =>      '&#x03A4',\r
-                       '&Upsilon'      =>      '&#x03A5',\r
-                       '&Phi'          =>      '&#x03A6',\r
-                       '&Chi'          =>      '&#x03A7',\r
-                       '&Psi'          =>      '&#x03A8',\r
-                       '&Omega'        =>      '&#x03A9',\r
-                       '&alpha'        =>      '&#x03B1',\r
-                       '&beta' =>      '&#x03B2',\r
-                       '&gamma'        =>      '&#x03B3',\r
-                       '&delta'        =>      '&#x03B4',\r
-                       '&epsilon'      =>      '&#x03B5',\r
-                       '&zeta' =>      '&#x03B6',\r
-                       '&eta'          =>      '&#x03B7',\r
-                       '&theta'        =>      '&#x03B8',\r
-                       '&iota' =>      '&#x03B9',\r
-                       '&kappa'        =>      '&#x03BA',\r
-                       '&lambda'       =>      '&#x03BB',\r
-                       '&mu'           =>      '&#x03BC',\r
-                       '&nu'           =>      '&#x03BD',\r
-                       '&xi'           =>      '&#x03BE',\r
-                       '&omicron'      =>      '&#x03BF',\r
-                       '&pi'           =>      '&#x03C0',\r
-                       '&rho'          =>      '&#x03C1',\r
-                       '&sigmaf'       =>      '&#x03C2',\r
-                       '&sigma'        =>      '&#x03C3',\r
-                       '&tau'          =>      '&#x03C4',\r
-                       '&upsilon'      =>      '&#x03C5',\r
-                       '&phi'          =>      '&#x03C6',\r
-                       '&chi'          =>      '&#x03C7',\r
-                       '&psi'          =>      '&#x03C8',\r
-                       '&omega'        =>      '&#x03C9',\r
-                       '&thetasym'     =>      '&#x03D1',\r
-                       '&upsih'        =>      '&#x03D2',\r
-                       '&piv'          =>      '&#x03D6',\r
-                       '&bull' =>      '&#x2022',\r
-                       '&hellip'       =>      '&#x2026',\r
-                       '&prime'        =>      '&#x2032',\r
-                       '&Prime'        =>      '&#x2033',\r
-                       '&oline'        =>      '&#x203E',\r
-                       '&frasl'        =>      '&#x2044',\r
-                       '&weierp'       =>      '&#x2118',\r
-                       '&image'        =>      '&#x2111',\r
-                       '&real' =>      '&#x211C',\r
-                       '&trade'        =>      '&#x2112',\r
-                       '&alefsym'      =>      '&#x2135',\r
-                       '&larr' =>      '&#x2190',\r
-                       '&uarr' =>      '&#x2191',\r
-                       '&rarr' =>      '&#x2192',\r
-                       '&darr' =>      '&#x2193',\r
-                       '&harr' =>      '&#x2194',\r
-                       '&crarr'        =>      '&#x21B5',\r
-                       '&lArr' =>      '&#x21D0',\r
-                       '&uArr' =>      '&#x21D1',\r
-                       '&rArr' =>      '&#x21D2',\r
-                       '&dArr' =>      '&#x21D3',\r
-                       '&hArr' =>      '&#x21D4',\r
-                       '&forall'       =>      '&#x2200',\r
-                       '&part' =>      '&#x2202',\r
-                       '&exist'        =>      '&#x2203',\r
-                       '&empty'        =>      '&#x2205',\r
-                       '&nabla'        =>      '&#x2207',\r
-                       '&isin' =>      '&#x2208',\r
-                       '&notin'        =>      '&#x2209',\r
-                       '&ni'           =>      '&#x220B',\r
-                       '&prod' =>      '&#x220F',\r
-                       '&sum'          =>      '&#x2211',\r
-                       '&minus'        =>      '&#x2212',\r
-                       '&lowast'       =>      '&#x2217',\r
-                       '&radic'        =>      '&#x221A',\r
-                       '&prop' =>      '&#x221D',\r
-                       '&infin'        =>      '&#x221E',\r
-                       '&ang'          =>      '&#x2220',\r
-                       '&and'          =>      '&#x2227',\r
-                       '&or'           =>      '&#x2228',\r
-                       '&cap'          =>      '&#x2229',\r
-                       '&cup'          =>      '&#x222A',\r
-                       '&int'          =>      '&#x222B',\r
-                       '&there4'       =>      '&#x2234',\r
-                       '&sim'          =>      '&#x223C',\r
-                       '&cong' =>      '&#x2245',\r
-                       '&asymp'        =>      '&#x2248',\r
-                       '&ne'           =>      '&#x2260',\r
-                       '&equiv'        =>      '&#x2261',\r
-                       '&le'           =>      '&#x2264',\r
-                       '&ge'           =>      '&#x2265',\r
-                       '&sub'          =>      '&#x2282',\r
-                       '&sup'          =>      '&#x2283',\r
-                       '&nsub' =>      '&#x2284',\r
-                       '&sube' =>      '&#x2286',\r
-                       '&supe' =>      '&#x2287',\r
-                       '&oplus'        =>      '&#x2295',\r
-                       '&otimes'       =>      '&#x2296',\r
-                       '&perp' =>      '&#x22A5',\r
-                       '&sdot' =>      '&#x22C5',\r
-                       '&lceil'        =>      '&#x2368',\r
-                       '&rceil'        =>      '&#x2309',\r
-                       '&lfloor'       =>      '&#x230A',\r
-                       '&rfloor'       =>      '&#x230B',\r
-                       '&lang' =>      '&#x2329',\r
-                       '&rang' =>      '&#x2330',\r
-                       '&loz'          =>      '&#x25CA',\r
-                       '&spades'       =>      '&#x2660',\r
-                       '&clubs'        =>      '&#x2663',\r
-                       '&hearts'       =>      '&#x2665',\r
-                       '&diams'        =>      '&#x2666'\r
-               ),\r
-               'Windows-1252' => array(\r
-                       '&#x80;'        =>      '&#x20AC;',\r
-                       '&#x82;'        =>      '&#x201A;',\r
-                       '&#x83;'        =>      '&#x0192;',\r
-                       '&#x84;'        =>      '&#x201E;',\r
-                       '&#x85;'        =>      '&#x2026;',\r
-                       '&#x86;'        =>      '&#x2020;',\r
-                       '&#x87;'        =>      '&#x2021;',\r
-                       '&#x88;'        =>      '&#x02C6;',\r
-                       '&#x89;'        =>      '&#x2030;',\r
-                       '&#x8A;'        =>      '&#x0160;',\r
-                       '&#x8B;'        =>      '&#x2039;',\r
-                       '&#x8C;'        =>      '&#x0152;',\r
-                       '&#x8E;'        =>      '&#x017D;',\r
-                       '&#x91;'        =>      '&#x2018;',\r
-                       '&#x92;'        =>      '&#x2019;',\r
-                       '&#x93;'        =>      '&#x201C;',\r
-                       '&#x94;'        =>      '&#x201D;',\r
-                       '&#x95;'        =>      '&#x2022;',\r
-                       '&#x96;'        =>      '&#x2013;',\r
-                       '&#x97;'        =>      '&#x2014;',\r
-                       '&#x98;'        =>      '&#x02DC;',\r
-                       '&#x99;'        =>      '&#x2122;',\r
-                       '&#x9A;'        =>      '&#x0161;',\r
-                       '&#x9B;'        =>      '&#x203A;',\r
-                       '&#x9C;'        =>      '&#x0153;',\r
-                       '&#x9E;'        =>      '&#x017E;',\r
-                       '&#x9F;'        =>      '&#x0178;',\r
-               )\r
-       );\r
-}\r
+<?php
+
+class Entity
+{
+       /**
+        * Entity::hen
+        * htmlentities wrapper
+        * 
+        * @static
+        * @access public
+        * @param       string  $string target string
+        * @param       string  $quotation      quotation mode. please refer to the argument of PHP built-in htmlentities
+        * @return      string  escaped string
+        */
+       static public function hen($string, $quotation=ENT_QUOTES)
+       {
+               /*
+                * we can use 'double_encode' flag instead of this when dropping supports for PHP 5.2.2 or lower
+                */
+               $string = html_entity_decode($string, $quotation, i18n::get_current_charset());
+               return (string) htmlentities($string, $quotation, i18n::get_current_charset());
+       }
+       
+       /**
+        * Entity::hsc
+        * htmlspecialchars wrapper
+        * 
+        * NOTE: htmlspecialchars_decode() is ASCII-to-ACII conversion
+        *  and its target string consists of several letters.
+        *   There are no problems.
+        * 
+        * @static
+        * @access public
+        * @param       string  $string target string
+        * @param       string  $quotation      quotation mode. please refer to the argument of PHP built-in htmlspecialchars
+        * @return      string  escaped string
+        * 
+        */
+       static public function hsc($string, $quotation=ENT_QUOTES)
+       {
+               /*
+                * we can use 'double_encode' flag instead of this when dropping supports for PHP 5.2.2 or lower
+                */
+               $string = htmlspecialchars_decode($string, $quotation);
+               return (string) htmlspecialchars($string, $quotation, i18n::get_current_charset());
+       }
+       
+       /**
+        * Entity::strip_tags()
+        * Strip HTML tags from a string
+        * 
+        * This function is a bit more intelligent than a regular call to strip_tags(),
+        * because it also deletes the contents of certain tags and cleans up any
+        * unneeded whitespace.
+        * 
+        * @static
+        * @param       String  $string target string
+        * @return      String  string with stripped tags
+        */
+       static public function strip_tags($string)
+       {
+               $string = preg_replace("#<del[^>]*>.+<\/del[^>]*>#isU", '', $string);
+               $string = preg_replace("#<script[^>]*>.+<\/script[^>]*>#isU", '', $string);
+               $string = preg_replace("#<style[^>]*>.+<\/style[^>]*>#isU", '', $string);
+               $string = preg_replace('#>#', '> ', $string);
+               $string = preg_replace('#<#', ' <', $string);
+               $string = strip_tags($string);
+               $string = preg_replace("#\s+#", " ", $string);
+               $string = trim($string);
+               return $string;
+       }
+       
+       /**
+        * shortens a text string to maxlength.
+        * $suffix is what needs to be added at the end (end length is <= $maxlength)
+        *
+        * The purpose is to limit the width of string for rendered screen in web browser.
+        * So it depends on style sheet, browser's rendering scheme, client's system font.
+        *
+        * NOTE: In general, non-Latin font such as Japanese, Chinese, Cyrillic have two times as width as Latin fonts,
+        *  but this is not always correct, for example, rendered by proportional font.
+        *
+        * @static
+        * @param string $escaped_string target string
+        * @param integer $maxlength maximum length of return string which includes suffix
+        * @param string $suffix added in the end of shortened-string
+        * @return string
+        */
+       static public function shorten($string, $maxlength, $suffix)
+       {
+               static $flag;
+               
+               $decoded_entities_pcre = array();
+               $encoded_entities = array();
+               
+               /* 1. store html entities */
+               preg_match('#&[^&]+?;#', $string, $encoded_entities);
+               if ( !$encoded_entities )
+               {
+                       $flag = FALSE;
+               }
+               else
+               {
+                       $flag = TRUE;
+               }
+               if ( $flag )
+               {
+                       foreach ( $encoded_entities as $encoded_entity )
+                       {
+                               $decoded_entities_pcre[] = '#' . html_entity_decode($encoded_entity, ENT_QUOTES, i18n::get_current_charset()) . '#';
+                       }
+               }
+               
+               /* 2. decode string */
+               $string = html_entity_decode($string, ENT_QUOTES, i18n::get_current_charset());
+               
+               /* 3. shorten string and add suffix if string length is longer */
+               if ( i18n::strlen($string) > $maxlength - i18n::strlen($suffix) )
+               {
+                       $string = i18n::substr($string, 0, $maxlength - i18n::strlen($suffix) );
+                       $string .= $suffix;
+               }
+               
+               /* 4. recover entities */
+               if ( $flag )
+               {
+                       $string = preg_replace($decoded_entities_pcre, $encoded_entities, $string);
+               }
+               
+               return $string;
+       }
+       
+       /**
+        * Entity::highlight()
+        * highlights a specific query in a given HTML text (not within HTML tags)
+        * 
+        * @static
+        * @param       string $text text to be highlighted
+        * @param       string $expression regular expression to be matched (can be an array of expressions as well)
+        * @param       string $highlight highlight to be used (use \\0 to indicate the matched expression)
+        * @return      string
+        */
+       static public function highlight($text, $expression, $highlight)
+       {
+               if ( !$highlight || !$expression )
+               {
+                       return $text;
+               }
+               
+               if ( is_array($expression) && (count($expression) == 0) )
+               {
+                       return $text;
+               }
+               
+               $text = "<!--h-->{$text}";
+               preg_match_all('#(<[^>]+>)([^<>]*)#', $text, $matches);
+               $result = '';
+               $count = count($matches[2]);
+               
+               for ( $i = 0; $i < $count; $i++ )
+               {
+                       if ( $i != 0 )
+                       {
+                               $result .= $matches[1][$i];
+                       }
+                       
+                       if ( is_array($expression) )
+                       {
+                               foreach ( $expression as $regex )
+                               {
+                                               $matches[2][$i] = preg_replace("#{$regex}#i", $highlight, $matches[2][$i]);
+                               }
+                               $result .= $matches[2][$i];
+                       }
+                       else
+                       {
+                               $result .= preg_replace("#{$expression}#i", $highlight, $matches[2][$i]);
+                       }
+               }
+               return $result;
+       }
+       
+       /**
+        * Entity::anchor_footnoting()
+        * change strings with footnoticing generated from anchor elements
+        * 
+        * @static
+        * @param       String  $string strings which includes html elements
+        * @return      String  string with footnotes
+        */
+       static public function anchor_footnoting($string)
+       {
+               /* 1. detect anchor elements */
+               $anchors = array();
+               if ( !preg_match_all("#<a[^>]*href=[\"\']([^\"^']*)[\"\'][^>]*>([^<]*)<\/a>#i", $subject, $anchors) )
+               {
+                       return $string;
+               }
+               
+               /* 2. add footnotes */
+               $string .= "\n\n";
+               $count = 1;
+               foreach ( $anchors as $anchor )
+               {
+                       preg_replace("#{$anchor[0]}#", "{$anchor[2]} [{$count}] ", $subject);
+                       $subject .= "[{$count}] {$anchor[1]}\n";
+                       $count++;
+               }
+               
+               return strip_tags($ascii);
+       }
+       
+       /*
+        * NOTE: Obsoleted functions
+        */
+       
+       /**
+        * Entity::named_to_numeric()
+        * 
+        * @deprecated
+        * @param String $string
+        */
+       function named_to_numeric ($string)
+       {
+               $string = preg_replace('/(&[0-9A-Za-z]+)(;?\=?|([^A-Za-z0-9\;\:\.\-\_]))/e', "Entity::_named('\\1', '\\2') . '\\3'", $string);
+               return $string;
+       }
+       
+       /**
+        * Entity::named_to_numeric()
+        * 
+        * @deprecated
+        * @param String $string
+        */
+       function normalize_numeric ($string) {
+               $string = preg_replace('/&#([0-9]+)(;)?/e', "'&#x'.dechex('\\1').';'", $string);
+               $string = preg_replace('/&#[Xx](0)*([0-9A-Fa-f]+)(;?|([^A-Za-z0-9\;\:\.\-\_]))/e', "'&#x' . strtoupper('\\2') . ';\\4'", $string);
+               $string = strtr($string, self::$entities['Windows-1252']);
+               return $string;
+       }
+       
+       /**
+        * Entity::numeric_to_utf8()
+        * 
+        * @deprecated
+        * @param String $string
+        */
+       function numeric_to_utf8 ($string) {
+               $string = preg_replace('/&#([0-9]+)(;)?/e', "'&#x'.dechex('\\1').';'", $string);
+               $string = preg_replace('/&#[Xx](0)*([0-9A-Fa-f]+)(;?|([^A-Za-z0-9\;\:\.\-\_]))/e', "'&#x' . strtoupper('\\2') . ';\\4'", $string);
+               $string = preg_replace('/&#x([0-9A-Fa-f]+);/e', "Entity::_hex_to_utf8('\\1')", $string);                
+               return $string;         
+       }
+       
+       /**
+        * Entity::numeric_to_named()
+        * convert decimal and hexadecimal numeric character references into named character references
+        * 
+        * @deprecated
+        * @param String $string
+        */
+       function numeric_to_named ($string)
+       {
+               $string = preg_replace('/&#[Xx]([0-9A-Fa-f]+)/e', "'&#'.hexdec('\\1')", $string);
+               $string = strtr($string, array_flip(self::$entities['named_to_numeric']));
+               return $string; 
+       }
+       
+       /**
+        * Entity::specialchars()
+        * convert HTML entities to named character reference
+        * 
+        * @deprecated
+        * @param String $string
+        */
+       function specialchars ($string, $type = 'xml')
+       {
+               $specialchars = array(
+                       '"'             => '&quot;',
+                       '&'             => '&amp;',
+                       '<'             => '&lt;',
+                       '>'             => '&gt;'
+               );
+               if ( $type != 'xml' )
+               {
+                       $specialchars["'"] = '&#39;';
+               }
+               else
+               {
+                       $specialchars["'"] = '&apos;';
+               }
+               
+               $string = preg_replace('/&(#?[Xx]?[0-9A-Za-z]+);/', "[[[ENTITY:\\1]]]", $string);
+               $string = strtr($string, $specialchars);
+               $string = preg_replace('/\[\[\[ENTITY\:([^\]]+)\]\]\]/', "&\\1;", $string);             
+               return $string;
+       }
+       
+       /**
+        * Entity::_hex_to_utf8()
+        * convert decimal numeric character references to hexadecimal numeric character references
+        * 
+        * @deprecated
+        * @param String $string
+        */
+       function _hex_to_utf8($s)
+       {
+               $c = hexdec($s);
+               
+               if ( $c < 0x80 )
+               {
+                       $str = chr($c);
+               }
+               else if ( $c < 0x800 )
+               {
+                       $str = chr(0xC0 | $c>>6) . chr(0x80 | $c & 0x3F);
+               }
+               else if ( $c < 0x10000 )
+               {
+                       $str = chr(0xE0 | $c>>12) . chr(0x80 | $c>>6 & 0x3F) . chr(0x80 | $c & 0x3F);
+               }
+               else if ( $c < 0x200000 )
+               {
+                       $str = chr(0xF0 | $c>>18) . chr(0x80 | $c>>12 & 0x3F) . chr(0x80 | $c>>6 & 0x3F) . chr(0x80 | $c & 0x3F);
+               }
+               return $str;
+       }
+       
+       /**
+        * Entity::_named()
+        * convert entities to named character reference
+        * 
+        * @deprecated
+        * @param String $string
+        * @param       String  $extra
+        * @return      
+        */
+       function _named($entity, $extra)
+       {
+               if ( $extra == '=' )
+               {
+                       return $entity . '=';
+               }
+               
+               $length = i18n::strlen($entity);
+               
+               while ( $length > 0 )
+               {
+                       $check = i18n::substr($entity, 0, $length);
+                       if ( array_key_exists($check, self::$entities['named_to_numeric']) )
+                       {
+                               return self::$entities['named_to_numeric'][$check] . ';' . i18n::substr($entity, $length);
+                       }
+                       $length--;
+               }
+               
+               if ( $extra != ';' )
+               {
+                       return $entity;
+               }
+               else
+               {
+                       return "{$entity};";
+               }
+       }
+       
+       /**
+        * ENTITIY::$entities
+        * 
+        * HTML 4.01 Specification
+        * @link        http://www.w3.org/TR/html4/sgml/entities.html
+        * @see 24 Character entity references in HTML 4
+        * 
+        * XHTML™ 1.0 The Extensible HyperText Markup Language (Second Edition)
+        *  A Reformulation of HTML 4 in XML 1.0
+        * @link        http://www.w3.org/TR/xhtml1/
+        * @see 4.12. Entity references as hex values
+        * @see C.16. The Named Character Reference &apos;
+        * 
+        * @static
+        * @deprecated
+        */
+       static private $entities = array (
+               'named_to_numeric' => array (
+                       '&nbsp' =>      '&#x00A0',
+                       '&iexcl'        =>      '&#x00A1',
+                       '&cent' =>      '&#x00A2',
+                       '&pound'        =>      '&#x00A3',
+                       '&curren'       =>      '&#x00A4',
+                       '&yen'          =>      '&#x00A5',
+                       '&brvbar'       =>      '&#x00A6',
+                       '&sect' =>      '&#x00A7',
+                       '&uml'          =>      '&#x00A8',
+                       '&copy' =>      '&#x00A9',
+                       '&ordf' =>      '&#x00AA',
+                       '&laquo'        =>      '&#x00AB',
+                       '&not'          =>      '&#x00AC',
+                       '&shy'          =>      '&#x00AD',
+                       '&reg'          =>      '&#x00AE',
+                       '&macr' =>      '&#x00AF',
+                       '&deg'          =>      '&#x00B0',
+                       '&plusmn'       =>      '&#x00B1',
+                       '&sup2' =>      '&#x00B2',
+                       '&sup3' =>      '&#x00B3',
+                       '&acute'        =>      '&#x00B4',
+                       '&micro'        =>      '&#x00B5',
+                       '&para' =>      '&#x00B6',
+                       '&middot'       =>      '&#x00B7',
+                       '&cedil'        =>      '&#x00B8',
+                       '&sup1' =>      '&#x00B9',
+                       '&ordm' =>      '&#x00BA',
+                       '&raquo'        =>      '&#x00BB',
+                       '&frac14'       =>      '&#x00BC',
+                       '&frac12'       =>      '&#x00BD',
+                       '&frac34'       =>      '&#x00BE',
+                       '&iquest'       =>      '&#x00BF',
+                       '&Agrave'       =>      '&#x00C0',
+                       '&Aacute'       =>      '&#x00C1',
+                       '&Acirc'        =>      '&#x00C2',
+                       '&Atilde'       =>      '&#x00C3',
+                       '&Auml' =>      '&#x00C4',
+                       '&Aring'        =>      '&#x00C5',
+                       '&AElig'        =>      '&#x00C6',
+                       '&Ccedil'       =>      '&#x00C7',
+                       '&Egrave'       =>      '&#x00C8',
+                       '&Eacute'       =>      '&#x00C9',
+                       '&Ecirc'        =>      '&#x00CA',
+                       '&Euml' =>      '&#x00CB',
+                       '&Igrave'       =>      '&#x00CC',
+                       '&Iacute'       =>      '&#x00CD',
+                       '&Icirc'        =>      '&#x00CE',
+                       '&Iuml' =>      '&#x00CF',
+                       '&ETH'          =>      '&#x00D0',
+                       '&Ntilde'       =>      '&#x00D1',
+                       '&Ograve'       =>      '&#x00D2',
+                       '&Oacute'       =>      '&#x00D3',
+                       '&Ocirc'        =>      '&#x00D4',
+                       '&Otilde'       =>      '&#x00D5',
+                       '&Ouml' =>      '&#x00D6',
+                       '&times'        =>      '&#x00D7',
+                       '&Oslash'       =>      '&#x00D8',
+                       '&Ugrave'       =>      '&#x00D9',
+                       '&Uacute'       =>      '&#x00DA',
+                       '&Ucirc'        =>      '&#x00DB',
+                       '&Uuml' =>      '&#x00DC',
+                       '&Yacute'       =>      '&#x00DD',
+                       '&THORN'        =>      '&#x00DE',
+                       '&szlig'        =>      '&#x00DF',
+                       '&agrave'       =>      '&#x00E0',
+                       '&aacute'       =>      '&#x00E1',
+                       '&acirc'        =>      '&#x00E2',
+                       '&atilde'       =>      '&#x00E3',
+                       '&auml' =>      '&#x00E4',
+                       '&aring'        =>      '&#x00E5',
+                       '&aelig'        =>      '&#x00E6',
+                       '&ccedil'       =>      '&#x00E7',
+                       '&egrave'       =>      '&#x00E8',
+                       '&eacute'       =>      '&#x00E9',
+                       '&ecirc'        =>      '&#x00EA',
+                       '&euml' =>      '&#x00EB',
+                       '&igrave'       =>      '&#x00EC',
+                       '&iacute'       =>      '&#x00ED',
+                       '&icirc'        =>      '&#x00EE',
+                       '&iuml' =>      '&#x00EF',
+                       '&eth'          =>      '&#x00F0',
+                       '&ntilde'       =>      '&#x00F1',
+                       '&ograve'       =>      '&#x00F2',
+                       '&oacute'       =>      '&#x00F3',
+                       '&ocirc'        =>      '&#x00F4',
+                       '&otilde'       =>      '&#x00F5',
+                       '&ouml' =>      '&#x00F6',
+                       '&divide'       =>      '&#x00F7',
+                       '&oslash'       =>      '&#x00F8',
+                       '&ugrave'       =>      '&#x00F9',
+                       '&uacute'       =>      '&#x00FA',
+                       '&ucirc'        =>      '&#x00FB',
+                       '&uuml' =>      '&#x00FC',
+                       '&yacute'       =>      '&#x00FD',
+                       '&thorn'        =>      '&#x00FE',
+                       '&yuml' =>      '&#x00FF',
+                       '&OElig'        =>      '&#x0152',
+                       '&oelig'        =>      '&#x00E5',
+                       '&Scaron'       =>      '&#x0160',
+                       '&scaron'       =>      '&#x0161',
+                       '&Yuml' =>      '&#x0178',
+                       '&circ' =>      '&#x02C6',
+                       '&tilde'        =>      '&#x02DC',
+                       '&esnp' =>      '&#x2002',
+                       '&emsp' =>      '&#x2003',
+                       '&thinsp'       =>      '&#x2009',
+                       '&zwnj' =>      '&#x200C',
+                       '&zwj'          =>      '&#x200D',
+                       '&lrm'          =>      '&#x200E',
+                       '&rlm'          =>      '&#x200F',
+                       '&ndash'        =>      '&#x2013',
+                       '&mdash'        =>      '&#x2014',
+                       '&lsquo'        =>      '&#x2018',
+                       '&rsquo'        =>      '&#x2019',
+                       '&sbquo'        =>      '&#x201A',
+                       '&ldquo'        =>      '&#x201C',
+                       '&rdquo'        =>      '&#x201D',
+                       '&bdquo'        =>      '&#x201E',
+                       '&dagger'       =>      '&#x2020',
+                       '&Dagger'       =>      '&#x2021',
+                       '&permil'       =>      '&#x2030',
+                       '&lsaquo'       =>      '&#x2039',
+                       '&rsaquo'       =>      '&#x203A',
+                       '&euro' =>      '&#x20AC',
+                       '&fnof' =>      '&#x0192',
+                       '&Alpha'        =>      '&#x0391',
+                       '&Beta' =>      '&#x0392',
+                       '&Gamma'        =>      '&#x0393',
+                       '&Delta'        =>      '&#x0394',
+                       '&Epsilon'      =>      '&#x0395',
+                       '&Zeta' =>      '&#x0396',
+                       '&Eta'          =>      '&#x0397',
+                       '&Theta'        =>      '&#x0398',
+                       '&Iota' =>      '&#x0399',
+                       '&Kappa'        =>      '&#x039A',
+                       '&Lambda'       =>      '&#x039B',
+                       '&Mu'           =>      '&#x039C',
+                       '&Nu'           =>      '&#x039D',
+                       '&Xi'           =>      '&#x039E',
+                       '&Omicron'      =>      '&#x039F',
+                       '&Pi'           =>      '&#x03A0',
+                       '&Rho'          =>      '&#x03A1',
+                       '&Sigma'        =>      '&#x03A3',
+                       '&Tau'          =>      '&#x03A4',
+                       '&Upsilon'      =>      '&#x03A5',
+                       '&Phi'          =>      '&#x03A6',
+                       '&Chi'          =>      '&#x03A7',
+                       '&Psi'          =>      '&#x03A8',
+                       '&Omega'        =>      '&#x03A9',
+                       '&alpha'        =>      '&#x03B1',
+                       '&beta' =>      '&#x03B2',
+                       '&gamma'        =>      '&#x03B3',
+                       '&delta'        =>      '&#x03B4',
+                       '&epsilon'      =>      '&#x03B5',
+                       '&zeta' =>      '&#x03B6',
+                       '&eta'          =>      '&#x03B7',
+                       '&theta'        =>      '&#x03B8',
+                       '&iota' =>      '&#x03B9',
+                       '&kappa'        =>      '&#x03BA',
+                       '&lambda'       =>      '&#x03BB',
+                       '&mu'           =>      '&#x03BC',
+                       '&nu'           =>      '&#x03BD',
+                       '&xi'           =>      '&#x03BE',
+                       '&omicron'      =>      '&#x03BF',
+                       '&pi'           =>      '&#x03C0',
+                       '&rho'          =>      '&#x03C1',
+                       '&sigmaf'       =>      '&#x03C2',
+                       '&sigma'        =>      '&#x03C3',
+                       '&tau'          =>      '&#x03C4',
+                       '&upsilon'      =>      '&#x03C5',
+                       '&phi'          =>      '&#x03C6',
+                       '&chi'          =>      '&#x03C7',
+                       '&psi'          =>      '&#x03C8',
+                       '&omega'        =>      '&#x03C9',
+                       '&thetasym'     =>      '&#x03D1',
+                       '&upsih'        =>      '&#x03D2',
+                       '&piv'          =>      '&#x03D6',
+                       '&bull' =>      '&#x2022',
+                       '&hellip'       =>      '&#x2026',
+                       '&prime'        =>      '&#x2032',
+                       '&Prime'        =>      '&#x2033',
+                       '&oline'        =>      '&#x203E',
+                       '&frasl'        =>      '&#x2044',
+                       '&weierp'       =>      '&#x2118',
+                       '&image'        =>      '&#x2111',
+                       '&real' =>      '&#x211C',
+                       '&trade'        =>      '&#x2112',
+                       '&alefsym'      =>      '&#x2135',
+                       '&larr' =>      '&#x2190',
+                       '&uarr' =>      '&#x2191',
+                       '&rarr' =>      '&#x2192',
+                       '&darr' =>      '&#x2193',
+                       '&harr' =>      '&#x2194',
+                       '&crarr'        =>      '&#x21B5',
+                       '&lArr' =>      '&#x21D0',
+                       '&uArr' =>      '&#x21D1',
+                       '&rArr' =>      '&#x21D2',
+                       '&dArr' =>      '&#x21D3',
+                       '&hArr' =>      '&#x21D4',
+                       '&forall'       =>      '&#x2200',
+                       '&part' =>      '&#x2202',
+                       '&exist'        =>      '&#x2203',
+                       '&empty'        =>      '&#x2205',
+                       '&nabla'        =>      '&#x2207',
+                       '&isin' =>      '&#x2208',
+                       '&notin'        =>      '&#x2209',
+                       '&ni'           =>      '&#x220B',
+                       '&prod' =>      '&#x220F',
+                       '&sum'          =>      '&#x2211',
+                       '&minus'        =>      '&#x2212',
+                       '&lowast'       =>      '&#x2217',
+                       '&radic'        =>      '&#x221A',
+                       '&prop' =>      '&#x221D',
+                       '&infin'        =>      '&#x221E',
+                       '&ang'          =>      '&#x2220',
+                       '&and'          =>      '&#x2227',
+                       '&or'           =>      '&#x2228',
+                       '&cap'          =>      '&#x2229',
+                       '&cup'          =>      '&#x222A',
+                       '&int'          =>      '&#x222B',
+                       '&there4'       =>      '&#x2234',
+                       '&sim'          =>      '&#x223C',
+                       '&cong' =>      '&#x2245',
+                       '&asymp'        =>      '&#x2248',
+                       '&ne'           =>      '&#x2260',
+                       '&equiv'        =>      '&#x2261',
+                       '&le'           =>      '&#x2264',
+                       '&ge'           =>      '&#x2265',
+                       '&sub'          =>      '&#x2282',
+                       '&sup'          =>      '&#x2283',
+                       '&nsub' =>      '&#x2284',
+                       '&sube' =>      '&#x2286',
+                       '&supe' =>      '&#x2287',
+                       '&oplus'        =>      '&#x2295',
+                       '&otimes'       =>      '&#x2296',
+                       '&perp' =>      '&#x22A5',
+                       '&sdot' =>      '&#x22C5',
+                       '&lceil'        =>      '&#x2368',
+                       '&rceil'        =>      '&#x2309',
+                       '&lfloor'       =>      '&#x230A',
+                       '&rfloor'       =>      '&#x230B',
+                       '&lang' =>      '&#x2329',
+                       '&rang' =>      '&#x2330',
+                       '&loz'          =>      '&#x25CA',
+                       '&spades'       =>      '&#x2660',
+                       '&clubs'        =>      '&#x2663',
+                       '&hearts'       =>      '&#x2665',
+                       '&diams'        =>      '&#x2666'
+               ),
+               'Windows-1252' => array(
+                       '&#x80;'        =>      '&#x20AC;',
+                       '&#x82;'        =>      '&#x201A;',
+                       '&#x83;'        =>      '&#x0192;',
+                       '&#x84;'        =>      '&#x201E;',
+                       '&#x85;'        =>      '&#x2026;',
+                       '&#x86;'        =>      '&#x2020;',
+                       '&#x87;'        =>      '&#x2021;',
+                       '&#x88;'        =>      '&#x02C6;',
+                       '&#x89;'        =>      '&#x2030;',
+                       '&#x8A;'        =>      '&#x0160;',
+                       '&#x8B;'        =>      '&#x2039;',
+                       '&#x8C;'        =>      '&#x0152;',
+                       '&#x8E;'        =>      '&#x017D;',
+                       '&#x91;'        =>      '&#x2018;',
+                       '&#x92;'        =>      '&#x2019;',
+                       '&#x93;'        =>      '&#x201C;',
+                       '&#x94;'        =>      '&#x201D;',
+                       '&#x95;'        =>      '&#x2022;',
+                       '&#x96;'        =>      '&#x2013;',
+                       '&#x97;'        =>      '&#x2014;',
+                       '&#x98;'        =>      '&#x02DC;',
+                       '&#x99;'        =>      '&#x2122;',
+                       '&#x9A;'        =>      '&#x0161;',
+                       '&#x9B;'        =>      '&#x203A;',
+                       '&#x9C;'        =>      '&#x0153;',
+                       '&#x9E;'        =>      '&#x017E;',
+                       '&#x9F;'        =>      '&#x0178;',
+               )
+       );
+}