OSDN Git Service

Merge branch 'skinnable-master'
[nucleus-jp/nucleus-next.git] / nucleus / libs / ENTITY.php
1 <?php
2
3 class Entity
4 {
5         /**
6          * Entity::hen
7          * htmlentities wrapper
8          * 
9          * @static
10          * @access public
11          * @param       string  $string target string
12          * @param       string  $quotation      quotation mode. please refer to the argument of PHP built-in htmlentities
13          * @return      string  escaped string
14          */
15         static public function hen($string, $quotation=ENT_QUOTES)
16         {
17                 /*
18                  * we can use 'double_encode' flag instead of this when dropping supports for PHP 5.2.2 or lower
19                  */
20                 $string = html_entity_decode($string, $quotation, i18n::get_current_charset());
21                 return (string) htmlentities($string, $quotation, i18n::get_current_charset());
22         }
23         
24         /**
25          * Entity::hsc
26          * htmlspecialchars wrapper
27          * 
28          * NOTE: htmlspecialchars_decode() is ASCII-to-ACII conversion
29          *  and its target string consists of several letters.
30          *   There are no problems.
31          * 
32          * @static
33          * @access public
34          * @param       string  $string target string
35          * @param       string  $quotation      quotation mode. please refer to the argument of PHP built-in htmlspecialchars
36          * @return      string  escaped string
37          * 
38          */
39         static public function hsc($string, $quotation=ENT_QUOTES)
40         {
41                 /*
42                  * we can use 'double_encode' flag instead of this when dropping supports for PHP 5.2.2 or lower
43                  */
44                 $string = htmlspecialchars_decode($string, $quotation);
45                 return (string) htmlspecialchars($string, $quotation, i18n::get_current_charset());
46         }
47         
48         /**
49          * Entity::strip_tags()
50          * Strip HTML tags from a string
51          * 
52          * This function is a bit more intelligent than a regular call to strip_tags(),
53          * because it also deletes the contents of certain tags and cleans up any
54          * unneeded whitespace.
55          * 
56          * @static
57          * @param       String  $string target string
58          * @return      String  string with stripped tags
59          */
60         static public function strip_tags($string)
61         {
62                 $string = preg_replace("#<del[^>]*>.+<\/del[^>]*>#isU", '', $string);
63                 $string = preg_replace("#<script[^>]*>.+<\/script[^>]*>#isU", '', $string);
64                 $string = preg_replace("#<style[^>]*>.+<\/style[^>]*>#isU", '', $string);
65                 $string = preg_replace('#>#', '> ', $string);
66                 $string = preg_replace('#<#', ' <', $string);
67                 $string = strip_tags($string);
68                 $string = preg_replace("#\s+#", " ", $string);
69                 $string = trim($string);
70                 return $string;
71         }
72         
73         /**
74          * shortens a text string to maxlength.
75          * $suffix is what needs to be added at the end (end length is <= $maxlength)
76          *
77          * The purpose is to limit the width of string for rendered screen in web browser.
78          * So it depends on style sheet, browser's rendering scheme, client's system font.
79          *
80          * NOTE: In general, non-Latin font such as Japanese, Chinese, Cyrillic have two times as width as Latin fonts,
81          *  but this is not always correct, for example, rendered by proportional font.
82          *
83          * @static
84          * @param string $escaped_string target string
85          * @param integer $maxlength maximum length of return string which includes suffix
86          * @param string $suffix added in the end of shortened-string
87          * @return string
88          */
89         static public function shorten($string, $maxlength, $suffix)
90         {
91                 static $flag;
92                 
93                 $decoded_entities_pcre = array();
94                 $encoded_entities = array();
95                 
96                 /* 1. store html entities */
97                 preg_match('#&[^&]+?;#', $string, $encoded_entities);
98                 if ( !$encoded_entities )
99                 {
100                         $flag = FALSE;
101                 }
102                 else
103                 {
104                         $flag = TRUE;
105                 }
106                 if ( $flag )
107                 {
108                         foreach ( $encoded_entities as $encoded_entity )
109                         {
110                                 $decoded_entities_pcre[] = '#' . html_entity_decode($encoded_entity, ENT_QUOTES, i18n::get_current_charset()) . '#';
111                         }
112                 }
113                 
114                 /* 2. decode string */
115                 $string = html_entity_decode($string, ENT_QUOTES, i18n::get_current_charset());
116                 
117                 /* 3. shorten string and add suffix if string length is longer */
118                 if ( i18n::strlen($string) > $maxlength - i18n::strlen($suffix) )
119                 {
120                         $string = i18n::substr($string, 0, $maxlength - i18n::strlen($suffix) );
121                         $string .= $suffix;
122                 }
123                 
124                 /* 4. recover entities */
125                 if ( $flag )
126                 {
127                         $string = preg_replace($decoded_entities_pcre, $encoded_entities, $string);
128                 }
129                 
130                 return $string;
131         }
132         
133         /**
134          * Entity::highlight()
135          * highlights a specific query in a given HTML text (not within HTML tags)
136          * 
137          * @static
138          * @param       string $text text to be highlighted
139          * @param       string $expression regular expression to be matched (can be an array of expressions as well)
140          * @param       string $highlight highlight to be used (use \\0 to indicate the matched expression)
141          * @return      string
142          */
143         static public function highlight($text, $expression, $highlight)
144         {
145                 if ( !$highlight || !$expression )
146                 {
147                         return $text;
148                 }
149                 
150                 if ( is_array($expression) && (count($expression) == 0) )
151                 {
152                         return $text;
153                 }
154                 
155                 $text = "<!--h-->{$text}";
156                 preg_match_all('#(<[^>]+>)([^<>]*)#', $text, $matches);
157                 $result = '';
158                 $count = count($matches[2]);
159                 
160                 for ( $i = 0; $i < $count; $i++ )
161                 {
162                         if ( $i != 0 )
163                         {
164                                 $result .= $matches[1][$i];
165                         }
166                         
167                         if ( is_array($expression) )
168                         {
169                                 foreach ( $expression as $regex )
170                                 {
171                                                 $matches[2][$i] = preg_replace("#{$regex}#i", $highlight, $matches[2][$i]);
172                                 }
173                                 $result .= $matches[2][$i];
174                         }
175                         else
176                         {
177                                 $result .= preg_replace("#{$expression}#i", $highlight, $matches[2][$i]);
178                         }
179                 }
180                 return $result;
181         }
182         
183         /**
184          * Entity::anchor_footnoting()
185          * change strings with footnoticing generated from anchor elements
186          * 
187          * @static
188          * @param       String  $string strings which includes html elements
189          * @return      String  string with footnotes
190          */
191         static public function anchor_footnoting($string)
192         {
193                 /* 1. detect anchor elements */
194                 $anchors = array();
195                 if ( !preg_match_all("#<a[^>]*href=[\"\']([^\"^']*)[\"\'][^>]*>([^<]*)<\/a>#i", $subject, $anchors) )
196                 {
197                         return $string;
198                 }
199                 
200                 /* 2. add footnotes */
201                 $string .= "\n\n";
202                 $count = 1;
203                 foreach ( $anchors as $anchor )
204                 {
205                         preg_replace("#{$anchor[0]}#", "{$anchor[2]} [{$count}] ", $subject);
206                         $subject .= "[{$count}] {$anchor[1]}\n";
207                         $count++;
208                 }
209                 
210                 return strip_tags($ascii);
211         }
212         
213         /*
214          * NOTE: Obsoleted functions
215          */
216         
217         /**
218          * Entity::named_to_numeric()
219          * 
220          * @deprecated
221          * @param String $string
222          */
223         function named_to_numeric ($string)
224         {
225                 $string = preg_replace('/(&[0-9A-Za-z]+)(;?\=?|([^A-Za-z0-9\;\:\.\-\_]))/e', "Entity::_named('\\1', '\\2') . '\\3'", $string);
226                 return $string;
227         }
228         
229         /**
230          * Entity::named_to_numeric()
231          * 
232          * @deprecated
233          * @param String $string
234          */
235         function normalize_numeric ($string) {
236                 $string = preg_replace('/&#([0-9]+)(;)?/e', "'&#x'.dechex('\\1').';'", $string);
237                 $string = preg_replace('/&#[Xx](0)*([0-9A-Fa-f]+)(;?|([^A-Za-z0-9\;\:\.\-\_]))/e', "'&#x' . strtoupper('\\2') . ';\\4'", $string);
238                 $string = strtr($string, self::$entities['Windows-1252']);
239                 return $string;
240         }
241         
242         /**
243          * Entity::numeric_to_utf8()
244          * 
245          * @deprecated
246          * @param String $string
247          */
248         function numeric_to_utf8 ($string) {
249                 $string = preg_replace('/&#([0-9]+)(;)?/e', "'&#x'.dechex('\\1').';'", $string);
250                 $string = preg_replace('/&#[Xx](0)*([0-9A-Fa-f]+)(;?|([^A-Za-z0-9\;\:\.\-\_]))/e', "'&#x' . strtoupper('\\2') . ';\\4'", $string);
251                 $string = preg_replace('/&#x([0-9A-Fa-f]+);/e', "Entity::_hex_to_utf8('\\1')", $string);                
252                 return $string;         
253         }
254         
255         /**
256          * Entity::numeric_to_named()
257          * convert decimal and hexadecimal numeric character references into named character references
258          * 
259          * @deprecated
260          * @param String $string
261          */
262         function numeric_to_named ($string)
263         {
264                 $string = preg_replace('/&#[Xx]([0-9A-Fa-f]+)/e', "'&#'.hexdec('\\1')", $string);
265                 $string = strtr($string, array_flip(self::$entities['named_to_numeric']));
266                 return $string; 
267         }
268         
269         /**
270          * Entity::specialchars()
271          * convert HTML entities to named character reference
272          * 
273          * @deprecated
274          * @param String $string
275          */
276         function specialchars ($string, $type = 'xml')
277         {
278                 $specialchars = array(
279                         '"'             => '&quot;',
280                         '&'             => '&amp;',
281                         '<'             => '&lt;',
282                         '>'             => '&gt;'
283                 );
284                 if ( $type != 'xml' )
285                 {
286                         $specialchars["'"] = '&#39;';
287                 }
288                 else
289                 {
290                         $specialchars["'"] = '&apos;';
291                 }
292                 
293                 $string = preg_replace('/&(#?[Xx]?[0-9A-Za-z]+);/', "[[[ENTITY:\\1]]]", $string);
294                 $string = strtr($string, $specialchars);
295                 $string = preg_replace('/\[\[\[ENTITY\:([^\]]+)\]\]\]/', "&\\1;", $string);             
296                 return $string;
297         }
298         
299         /**
300          * Entity::_hex_to_utf8()
301          * convert decimal numeric character references to hexadecimal numeric character references
302          * 
303          * @deprecated
304          * @param String $string
305          */
306         function _hex_to_utf8($s)
307         {
308                 $c = hexdec($s);
309                 
310                 if ( $c < 0x80 )
311                 {
312                         $str = chr($c);
313                 }
314                 else if ( $c < 0x800 )
315                 {
316                         $str = chr(0xC0 | $c>>6) . chr(0x80 | $c & 0x3F);
317                 }
318                 else if ( $c < 0x10000 )
319                 {
320                         $str = chr(0xE0 | $c>>12) . chr(0x80 | $c>>6 & 0x3F) . chr(0x80 | $c & 0x3F);
321                 }
322                 else if ( $c < 0x200000 )
323                 {
324                         $str = chr(0xF0 | $c>>18) . chr(0x80 | $c>>12 & 0x3F) . chr(0x80 | $c>>6 & 0x3F) . chr(0x80 | $c & 0x3F);
325                 }
326                 return $str;
327         }
328         
329         /**
330          * Entity::_named()
331          * convert entities to named character reference
332          * 
333          * @deprecated
334          * @param String $string
335          * @param       String  $extra
336          * @return      
337          */
338         function _named($entity, $extra)
339         {
340                 if ( $extra == '=' )
341                 {
342                         return $entity . '=';
343                 }
344                 
345                 $length = i18n::strlen($entity);
346                 
347                 while ( $length > 0 )
348                 {
349                         $check = i18n::substr($entity, 0, $length);
350                         if ( array_key_exists($check, self::$entities['named_to_numeric']) )
351                         {
352                                 return self::$entities['named_to_numeric'][$check] . ';' . i18n::substr($entity, $length);
353                         }
354                         $length--;
355                 }
356                 
357                 if ( $extra != ';' )
358                 {
359                         return $entity;
360                 }
361                 else
362                 {
363                         return "{$entity};";
364                 }
365         }
366         
367         /**
368          * ENTITIY::$entities
369          * 
370          * HTML 4.01 Specification
371          * @link        http://www.w3.org/TR/html4/sgml/entities.html
372          * @see 24 Character entity references in HTML 4
373          * 
374          * XHTML™ 1.0 The Extensible HyperText Markup Language (Second Edition)
375          *  A Reformulation of HTML 4 in XML 1.0
376          * @link        http://www.w3.org/TR/xhtml1/
377          * @see 4.12. Entity references as hex values
378          * @see C.16. The Named Character Reference &apos;
379          * 
380          * @static
381          * @deprecated
382          */
383         static private $entities = array (
384                 'named_to_numeric' => array (
385                         '&nbsp' =>      '&#x00A0',
386                         '&iexcl'        =>      '&#x00A1',
387                         '&cent' =>      '&#x00A2',
388                         '&pound'        =>      '&#x00A3',
389                         '&curren'       =>      '&#x00A4',
390                         '&yen'          =>      '&#x00A5',
391                         '&brvbar'       =>      '&#x00A6',
392                         '&sect' =>      '&#x00A7',
393                         '&uml'          =>      '&#x00A8',
394                         '&copy' =>      '&#x00A9',
395                         '&ordf' =>      '&#x00AA',
396                         '&laquo'        =>      '&#x00AB',
397                         '&not'          =>      '&#x00AC',
398                         '&shy'          =>      '&#x00AD',
399                         '&reg'          =>      '&#x00AE',
400                         '&macr' =>      '&#x00AF',
401                         '&deg'          =>      '&#x00B0',
402                         '&plusmn'       =>      '&#x00B1',
403                         '&sup2' =>      '&#x00B2',
404                         '&sup3' =>      '&#x00B3',
405                         '&acute'        =>      '&#x00B4',
406                         '&micro'        =>      '&#x00B5',
407                         '&para' =>      '&#x00B6',
408                         '&middot'       =>      '&#x00B7',
409                         '&cedil'        =>      '&#x00B8',
410                         '&sup1' =>      '&#x00B9',
411                         '&ordm' =>      '&#x00BA',
412                         '&raquo'        =>      '&#x00BB',
413                         '&frac14'       =>      '&#x00BC',
414                         '&frac12'       =>      '&#x00BD',
415                         '&frac34'       =>      '&#x00BE',
416                         '&iquest'       =>      '&#x00BF',
417                         '&Agrave'       =>      '&#x00C0',
418                         '&Aacute'       =>      '&#x00C1',
419                         '&Acirc'        =>      '&#x00C2',
420                         '&Atilde'       =>      '&#x00C3',
421                         '&Auml' =>      '&#x00C4',
422                         '&Aring'        =>      '&#x00C5',
423                         '&AElig'        =>      '&#x00C6',
424                         '&Ccedil'       =>      '&#x00C7',
425                         '&Egrave'       =>      '&#x00C8',
426                         '&Eacute'       =>      '&#x00C9',
427                         '&Ecirc'        =>      '&#x00CA',
428                         '&Euml' =>      '&#x00CB',
429                         '&Igrave'       =>      '&#x00CC',
430                         '&Iacute'       =>      '&#x00CD',
431                         '&Icirc'        =>      '&#x00CE',
432                         '&Iuml' =>      '&#x00CF',
433                         '&ETH'          =>      '&#x00D0',
434                         '&Ntilde'       =>      '&#x00D1',
435                         '&Ograve'       =>      '&#x00D2',
436                         '&Oacute'       =>      '&#x00D3',
437                         '&Ocirc'        =>      '&#x00D4',
438                         '&Otilde'       =>      '&#x00D5',
439                         '&Ouml' =>      '&#x00D6',
440                         '&times'        =>      '&#x00D7',
441                         '&Oslash'       =>      '&#x00D8',
442                         '&Ugrave'       =>      '&#x00D9',
443                         '&Uacute'       =>      '&#x00DA',
444                         '&Ucirc'        =>      '&#x00DB',
445                         '&Uuml' =>      '&#x00DC',
446                         '&Yacute'       =>      '&#x00DD',
447                         '&THORN'        =>      '&#x00DE',
448                         '&szlig'        =>      '&#x00DF',
449                         '&agrave'       =>      '&#x00E0',
450                         '&aacute'       =>      '&#x00E1',
451                         '&acirc'        =>      '&#x00E2',
452                         '&atilde'       =>      '&#x00E3',
453                         '&auml' =>      '&#x00E4',
454                         '&aring'        =>      '&#x00E5',
455                         '&aelig'        =>      '&#x00E6',
456                         '&ccedil'       =>      '&#x00E7',
457                         '&egrave'       =>      '&#x00E8',
458                         '&eacute'       =>      '&#x00E9',
459                         '&ecirc'        =>      '&#x00EA',
460                         '&euml' =>      '&#x00EB',
461                         '&igrave'       =>      '&#x00EC',
462                         '&iacute'       =>      '&#x00ED',
463                         '&icirc'        =>      '&#x00EE',
464                         '&iuml' =>      '&#x00EF',
465                         '&eth'          =>      '&#x00F0',
466                         '&ntilde'       =>      '&#x00F1',
467                         '&ograve'       =>      '&#x00F2',
468                         '&oacute'       =>      '&#x00F3',
469                         '&ocirc'        =>      '&#x00F4',
470                         '&otilde'       =>      '&#x00F5',
471                         '&ouml' =>      '&#x00F6',
472                         '&divide'       =>      '&#x00F7',
473                         '&oslash'       =>      '&#x00F8',
474                         '&ugrave'       =>      '&#x00F9',
475                         '&uacute'       =>      '&#x00FA',
476                         '&ucirc'        =>      '&#x00FB',
477                         '&uuml' =>      '&#x00FC',
478                         '&yacute'       =>      '&#x00FD',
479                         '&thorn'        =>      '&#x00FE',
480                         '&yuml' =>      '&#x00FF',
481                         '&OElig'        =>      '&#x0152',
482                         '&oelig'        =>      '&#x00E5',
483                         '&Scaron'       =>      '&#x0160',
484                         '&scaron'       =>      '&#x0161',
485                         '&Yuml' =>      '&#x0178',
486                         '&circ' =>      '&#x02C6',
487                         '&tilde'        =>      '&#x02DC',
488                         '&esnp' =>      '&#x2002',
489                         '&emsp' =>      '&#x2003',
490                         '&thinsp'       =>      '&#x2009',
491                         '&zwnj' =>      '&#x200C',
492                         '&zwj'          =>      '&#x200D',
493                         '&lrm'          =>      '&#x200E',
494                         '&rlm'          =>      '&#x200F',
495                         '&ndash'        =>      '&#x2013',
496                         '&mdash'        =>      '&#x2014',
497                         '&lsquo'        =>      '&#x2018',
498                         '&rsquo'        =>      '&#x2019',
499                         '&sbquo'        =>      '&#x201A',
500                         '&ldquo'        =>      '&#x201C',
501                         '&rdquo'        =>      '&#x201D',
502                         '&bdquo'        =>      '&#x201E',
503                         '&dagger'       =>      '&#x2020',
504                         '&Dagger'       =>      '&#x2021',
505                         '&permil'       =>      '&#x2030',
506                         '&lsaquo'       =>      '&#x2039',
507                         '&rsaquo'       =>      '&#x203A',
508                         '&euro' =>      '&#x20AC',
509                         '&fnof' =>      '&#x0192',
510                         '&Alpha'        =>      '&#x0391',
511                         '&Beta' =>      '&#x0392',
512                         '&Gamma'        =>      '&#x0393',
513                         '&Delta'        =>      '&#x0394',
514                         '&Epsilon'      =>      '&#x0395',
515                         '&Zeta' =>      '&#x0396',
516                         '&Eta'          =>      '&#x0397',
517                         '&Theta'        =>      '&#x0398',
518                         '&Iota' =>      '&#x0399',
519                         '&Kappa'        =>      '&#x039A',
520                         '&Lambda'       =>      '&#x039B',
521                         '&Mu'           =>      '&#x039C',
522                         '&Nu'           =>      '&#x039D',
523                         '&Xi'           =>      '&#x039E',
524                         '&Omicron'      =>      '&#x039F',
525                         '&Pi'           =>      '&#x03A0',
526                         '&Rho'          =>      '&#x03A1',
527                         '&Sigma'        =>      '&#x03A3',
528                         '&Tau'          =>      '&#x03A4',
529                         '&Upsilon'      =>      '&#x03A5',
530                         '&Phi'          =>      '&#x03A6',
531                         '&Chi'          =>      '&#x03A7',
532                         '&Psi'          =>      '&#x03A8',
533                         '&Omega'        =>      '&#x03A9',
534                         '&alpha'        =>      '&#x03B1',
535                         '&beta' =>      '&#x03B2',
536                         '&gamma'        =>      '&#x03B3',
537                         '&delta'        =>      '&#x03B4',
538                         '&epsilon'      =>      '&#x03B5',
539                         '&zeta' =>      '&#x03B6',
540                         '&eta'          =>      '&#x03B7',
541                         '&theta'        =>      '&#x03B8',
542                         '&iota' =>      '&#x03B9',
543                         '&kappa'        =>      '&#x03BA',
544                         '&lambda'       =>      '&#x03BB',
545                         '&mu'           =>      '&#x03BC',
546                         '&nu'           =>      '&#x03BD',
547                         '&xi'           =>      '&#x03BE',
548                         '&omicron'      =>      '&#x03BF',
549                         '&pi'           =>      '&#x03C0',
550                         '&rho'          =>      '&#x03C1',
551                         '&sigmaf'       =>      '&#x03C2',
552                         '&sigma'        =>      '&#x03C3',
553                         '&tau'          =>      '&#x03C4',
554                         '&upsilon'      =>      '&#x03C5',
555                         '&phi'          =>      '&#x03C6',
556                         '&chi'          =>      '&#x03C7',
557                         '&psi'          =>      '&#x03C8',
558                         '&omega'        =>      '&#x03C9',
559                         '&thetasym'     =>      '&#x03D1',
560                         '&upsih'        =>      '&#x03D2',
561                         '&piv'          =>      '&#x03D6',
562                         '&bull' =>      '&#x2022',
563                         '&hellip'       =>      '&#x2026',
564                         '&prime'        =>      '&#x2032',
565                         '&Prime'        =>      '&#x2033',
566                         '&oline'        =>      '&#x203E',
567                         '&frasl'        =>      '&#x2044',
568                         '&weierp'       =>      '&#x2118',
569                         '&image'        =>      '&#x2111',
570                         '&real' =>      '&#x211C',
571                         '&trade'        =>      '&#x2112',
572                         '&alefsym'      =>      '&#x2135',
573                         '&larr' =>      '&#x2190',
574                         '&uarr' =>      '&#x2191',
575                         '&rarr' =>      '&#x2192',
576                         '&darr' =>      '&#x2193',
577                         '&harr' =>      '&#x2194',
578                         '&crarr'        =>      '&#x21B5',
579                         '&lArr' =>      '&#x21D0',
580                         '&uArr' =>      '&#x21D1',
581                         '&rArr' =>      '&#x21D2',
582                         '&dArr' =>      '&#x21D3',
583                         '&hArr' =>      '&#x21D4',
584                         '&forall'       =>      '&#x2200',
585                         '&part' =>      '&#x2202',
586                         '&exist'        =>      '&#x2203',
587                         '&empty'        =>      '&#x2205',
588                         '&nabla'        =>      '&#x2207',
589                         '&isin' =>      '&#x2208',
590                         '&notin'        =>      '&#x2209',
591                         '&ni'           =>      '&#x220B',
592                         '&prod' =>      '&#x220F',
593                         '&sum'          =>      '&#x2211',
594                         '&minus'        =>      '&#x2212',
595                         '&lowast'       =>      '&#x2217',
596                         '&radic'        =>      '&#x221A',
597                         '&prop' =>      '&#x221D',
598                         '&infin'        =>      '&#x221E',
599                         '&ang'          =>      '&#x2220',
600                         '&and'          =>      '&#x2227',
601                         '&or'           =>      '&#x2228',
602                         '&cap'          =>      '&#x2229',
603                         '&cup'          =>      '&#x222A',
604                         '&int'          =>      '&#x222B',
605                         '&there4'       =>      '&#x2234',
606                         '&sim'          =>      '&#x223C',
607                         '&cong' =>      '&#x2245',
608                         '&asymp'        =>      '&#x2248',
609                         '&ne'           =>      '&#x2260',
610                         '&equiv'        =>      '&#x2261',
611                         '&le'           =>      '&#x2264',
612                         '&ge'           =>      '&#x2265',
613                         '&sub'          =>      '&#x2282',
614                         '&sup'          =>      '&#x2283',
615                         '&nsub' =>      '&#x2284',
616                         '&sube' =>      '&#x2286',
617                         '&supe' =>      '&#x2287',
618                         '&oplus'        =>      '&#x2295',
619                         '&otimes'       =>      '&#x2296',
620                         '&perp' =>      '&#x22A5',
621                         '&sdot' =>      '&#x22C5',
622                         '&lceil'        =>      '&#x2368',
623                         '&rceil'        =>      '&#x2309',
624                         '&lfloor'       =>      '&#x230A',
625                         '&rfloor'       =>      '&#x230B',
626                         '&lang' =>      '&#x2329',
627                         '&rang' =>      '&#x2330',
628                         '&loz'          =>      '&#x25CA',
629                         '&spades'       =>      '&#x2660',
630                         '&clubs'        =>      '&#x2663',
631                         '&hearts'       =>      '&#x2665',
632                         '&diams'        =>      '&#x2666'
633                 ),
634                 'Windows-1252' => array(
635                         '&#x80;'        =>      '&#x20AC;',
636                         '&#x82;'        =>      '&#x201A;',
637                         '&#x83;'        =>      '&#x0192;',
638                         '&#x84;'        =>      '&#x201E;',
639                         '&#x85;'        =>      '&#x2026;',
640                         '&#x86;'        =>      '&#x2020;',
641                         '&#x87;'        =>      '&#x2021;',
642                         '&#x88;'        =>      '&#x02C6;',
643                         '&#x89;'        =>      '&#x2030;',
644                         '&#x8A;'        =>      '&#x0160;',
645                         '&#x8B;'        =>      '&#x2039;',
646                         '&#x8C;'        =>      '&#x0152;',
647                         '&#x8E;'        =>      '&#x017D;',
648                         '&#x91;'        =>      '&#x2018;',
649                         '&#x92;'        =>      '&#x2019;',
650                         '&#x93;'        =>      '&#x201C;',
651                         '&#x94;'        =>      '&#x201D;',
652                         '&#x95;'        =>      '&#x2022;',
653                         '&#x96;'        =>      '&#x2013;',
654                         '&#x97;'        =>      '&#x2014;',
655                         '&#x98;'        =>      '&#x02DC;',
656                         '&#x99;'        =>      '&#x2122;',
657                         '&#x9A;'        =>      '&#x0161;',
658                         '&#x9B;'        =>      '&#x203A;',
659                         '&#x9C;'        =>      '&#x0153;',
660                         '&#x9E;'        =>      '&#x017E;',
661                         '&#x9F;'        =>      '&#x0178;',
662                 )
663         );
664 }