SimplePie: PHP-based RSS and Atom feed handling
 
  • Overview
  • Demo
  • Blog
  • Download
  • Documentation
  • API Docs
  • Support
  • Issue Tracker
  • FAQ
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated

Packages

  • SimplePie
    • API
    • Caching
    • HTTP
    • Parsing

Classes

  • SimplePie_Decode_HTML_Entities
  • SimplePie_Locator
  • SimplePie_Misc
  • SimplePie_Registry
  • SimplePie_Sanitize
   1: <?php
   2: /**
   3:  * SimplePie
   4:  *
   5:  * A PHP-Based RSS and Atom Feed Framework.
   6:  * Takes the hard work out of managing a complete RSS/Atom solution.
   7:  *
   8:  * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
   9:  * All rights reserved.
  10:  *
  11:  * Redistribution and use in source and binary forms, with or without modification, are
  12:  * permitted provided that the following conditions are met:
  13:  *
  14:  *  * Redistributions of source code must retain the above copyright notice, this list of
  15:  *    conditions and the following disclaimer.
  16:  *
  17:  *  * Redistributions in binary form must reproduce the above copyright notice, this list
  18:  *    of conditions and the following disclaimer in the documentation and/or other materials
  19:  *    provided with the distribution.
  20:  *
  21:  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
  22:  *    to endorse or promote products derived from this software without specific prior
  23:  *    written permission.
  24:  *
  25:  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  26:  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
  27:  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
  28:  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  29:  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  30:  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  31:  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  32:  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  33:  * POSSIBILITY OF SUCH DAMAGE.
  34:  *
  35:  * @package SimplePie
  36:  * @version 1.3
  37:  * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
  38:  * @author Ryan Parman
  39:  * @author Geoffrey Sneddon
  40:  * @author Ryan McCue
  41:  * @link http://simplepie.org/ SimplePie
  42:  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
  43:  */
  44: 
  45: /**
  46:  * Miscellanous utilities
  47:  *
  48:  * @package SimplePie
  49:  */
  50: class SimplePie_Misc
  51: {
  52:     public static function time_hms($seconds)
  53:     {
  54:         $time = '';
  55: 
  56:         $hours = floor($seconds / 3600);
  57:         $remainder = $seconds % 3600;
  58:         if ($hours > 0)
  59:         {
  60:             $time .= $hours.':';
  61:         }
  62: 
  63:         $minutes = floor($remainder / 60);
  64:         $seconds = $remainder % 60;
  65:         if ($minutes < 10 && $hours > 0)
  66:         {
  67:             $minutes = '0' . $minutes;
  68:         }
  69:         if ($seconds < 10)
  70:         {
  71:             $seconds = '0' . $seconds;
  72:         }
  73: 
  74:         $time .= $minutes.':';
  75:         $time .= $seconds;
  76: 
  77:         return $time;
  78:     }
  79: 
  80:     public static function absolutize_url($relative, $base)
  81:     {
  82:         $iri = SimplePie_IRI::absolutize(new SimplePie_IRI($base), $relative);
  83:         return $iri->get_uri();
  84:     }
  85: 
  86:     /**
  87:      * Get a HTML/XML element from a HTML string
  88:      *
  89:      * @deprecated Use DOMDocument instead (parsing HTML with regex is bad!)
  90:      * @param string $realname Element name (including namespace prefix if applicable)
  91:      * @param string $string HTML document
  92:      * @return array
  93:      */
  94:     public static function get_element($realname, $string)
  95:     {
  96:         $return = array();
  97:         $name = preg_quote($realname, '/');
  98:         if (preg_match_all("/<($name)" . SIMPLEPIE_PCRE_HTML_ATTRIBUTE . "(>(.*)<\/$name>|(\/)?>)/siU", $string, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE))
  99:         {
 100:             for ($i = 0, $total_matches = count($matches); $i < $total_matches; $i++)
 101:             {
 102:                 $return[$i]['tag'] = $realname;
 103:                 $return[$i]['full'] = $matches[$i][0][0];
 104:                 $return[$i]['offset'] = $matches[$i][0][1];
 105:                 if (strlen($matches[$i][3][0]) <= 2)
 106:                 {
 107:                     $return[$i]['self_closing'] = true;
 108:                 }
 109:                 else
 110:                 {
 111:                     $return[$i]['self_closing'] = false;
 112:                     $return[$i]['content'] = $matches[$i][4][0];
 113:                 }
 114:                 $return[$i]['attribs'] = array();
 115:                 if (isset($matches[$i][2][0]) && preg_match_all('/[\x09\x0A\x0B\x0C\x0D\x20]+([^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3D\x3E]*)(?:[\x09\x0A\x0B\x0C\x0D\x20]*=[\x09\x0A\x0B\x0C\x0D\x20]*(?:"([^"]*)"|\'([^\']*)\'|([^\x09\x0A\x0B\x0C\x0D\x20\x22\x27\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x3E]*)?))?/', ' ' . $matches[$i][2][0] . ' ', $attribs, PREG_SET_ORDER))
 116:                 {
 117:                     for ($j = 0, $total_attribs = count($attribs); $j < $total_attribs; $j++)
 118:                     {
 119:                         if (count($attribs[$j]) === 2)
 120:                         {
 121:                             $attribs[$j][2] = $attribs[$j][1];
 122:                         }
 123:                         $return[$i]['attribs'][strtolower($attribs[$j][1])]['data'] = SimplePie_Misc::entities_decode(end($attribs[$j]), 'UTF-8');
 124:                     }
 125:                 }
 126:             }
 127:         }
 128:         return $return;
 129:     }
 130: 
 131:     public static function element_implode($element)
 132:     {
 133:         $full = "<$element[tag]";
 134:         foreach ($element['attribs'] as $key => $value)
 135:         {
 136:             $key = strtolower($key);
 137:             $full .= " $key=\"" . htmlspecialchars($value['data']) . '"';
 138:         }
 139:         if ($element['self_closing'])
 140:         {
 141:             $full .= ' />';
 142:         }
 143:         else
 144:         {
 145:             $full .= ">$element[content]</$element[tag]>";
 146:         }
 147:         return $full;
 148:     }
 149: 
 150:     public static function error($message, $level, $file, $line)
 151:     {
 152:         if ((ini_get('error_reporting') & $level) > 0)
 153:         {
 154:             switch ($level)
 155:             {
 156:                 case E_USER_ERROR:
 157:                     $note = 'PHP Error';
 158:                     break;
 159:                 case E_USER_WARNING:
 160:                     $note = 'PHP Warning';
 161:                     break;
 162:                 case E_USER_NOTICE:
 163:                     $note = 'PHP Notice';
 164:                     break;
 165:                 default:
 166:                     $note = 'Unknown Error';
 167:                     break;
 168:             }
 169: 
 170:             $log_error = true;
 171:             if (!function_exists('error_log'))
 172:             {
 173:                 $log_error = false;
 174:             }
 175: 
 176:             $log_file = @ini_get('error_log');
 177:             if (!empty($log_file) && ('syslog' !== $log_file) && !@is_writable($log_file))
 178:             {
 179:                 $log_error = false;
 180:             }
 181: 
 182:             if ($log_error)
 183:             {
 184:                 @error_log("$note: $message in $file on line $line", 0);
 185:             }
 186:         }
 187: 
 188:         return $message;
 189:     }
 190: 
 191:     public static function fix_protocol($url, $http = 1)
 192:     {
 193:         $url = SimplePie_Misc::normalize_url($url);
 194:         $parsed = SimplePie_Misc::parse_url($url);
 195:         if ($parsed['scheme'] !== '' && $parsed['scheme'] !== 'http' && $parsed['scheme'] !== 'https')
 196:         {
 197:             return SimplePie_Misc::fix_protocol(SimplePie_Misc::compress_parse_url('http', $parsed['authority'], $parsed['path'], $parsed['query'], $parsed['fragment']), $http);
 198:         }
 199: 
 200:         if ($parsed['scheme'] === '' && $parsed['authority'] === '' && !file_exists($url))
 201:         {
 202:             return SimplePie_Misc::fix_protocol(SimplePie_Misc::compress_parse_url('http', $parsed['path'], '', $parsed['query'], $parsed['fragment']), $http);
 203:         }
 204: 
 205:         if ($http === 2 && $parsed['scheme'] !== '')
 206:         {
 207:             return "feed:$url";
 208:         }
 209:         elseif ($http === 3 && strtolower($parsed['scheme']) === 'http')
 210:         {
 211:             return substr_replace($url, 'podcast', 0, 4);
 212:         }
 213:         elseif ($http === 4 && strtolower($parsed['scheme']) === 'http')
 214:         {
 215:             return substr_replace($url, 'itpc', 0, 4);
 216:         }
 217:         else
 218:         {
 219:             return $url;
 220:         }
 221:     }
 222: 
 223:     public static function parse_url($url)
 224:     {
 225:         $iri = new SimplePie_IRI($url);
 226:         return array(
 227:             'scheme' => (string) $iri->scheme,
 228:             'authority' => (string) $iri->authority,
 229:             'path' => (string) $iri->path,
 230:             'query' => (string) $iri->query,
 231:             'fragment' => (string) $iri->fragment
 232:         );
 233:     }
 234: 
 235:     public static function compress_parse_url($scheme = '', $authority = '', $path = '', $query = '', $fragment = '')
 236:     {
 237:         $iri = new SimplePie_IRI('');
 238:         $iri->scheme = $scheme;
 239:         $iri->authority = $authority;
 240:         $iri->path = $path;
 241:         $iri->query = $query;
 242:         $iri->fragment = $fragment;
 243:         return $iri->get_uri();
 244:     }
 245: 
 246:     public static function normalize_url($url)
 247:     {
 248:         $iri = new SimplePie_IRI($url);
 249:         return $iri->get_uri();
 250:     }
 251: 
 252:     public static function percent_encoding_normalization($match)
 253:     {
 254:         $integer = hexdec($match[1]);
 255:         if ($integer >= 0x41 && $integer <= 0x5A || $integer >= 0x61 && $integer <= 0x7A || $integer >= 0x30 && $integer <= 0x39 || $integer === 0x2D || $integer === 0x2E || $integer === 0x5F || $integer === 0x7E)
 256:         {
 257:             return chr($integer);
 258:         }
 259:         else
 260:         {
 261:             return strtoupper($match[0]);
 262:         }
 263:     }
 264: 
 265:     /**
 266:      * Converts a Windows-1252 encoded string to a UTF-8 encoded string
 267:      *
 268:      * @static
 269:      * @param string $string Windows-1252 encoded string
 270:      * @return string UTF-8 encoded string
 271:      */
 272:     public static function windows_1252_to_utf8($string)
 273:     {
 274:         static $convert_table = array("\x80" => "\xE2\x82\xAC", "\x81" => "\xEF\xBF\xBD", "\x82" => "\xE2\x80\x9A", "\x83" => "\xC6\x92", "\x84" => "\xE2\x80\x9E", "\x85" => "\xE2\x80\xA6", "\x86" => "\xE2\x80\xA0", "\x87" => "\xE2\x80\xA1", "\x88" => "\xCB\x86", "\x89" => "\xE2\x80\xB0", "\x8A" => "\xC5\xA0", "\x8B" => "\xE2\x80\xB9", "\x8C" => "\xC5\x92", "\x8D" => "\xEF\xBF\xBD", "\x8E" => "\xC5\xBD", "\x8F" => "\xEF\xBF\xBD", "\x90" => "\xEF\xBF\xBD", "\x91" => "\xE2\x80\x98", "\x92" => "\xE2\x80\x99", "\x93" => "\xE2\x80\x9C", "\x94" => "\xE2\x80\x9D", "\x95" => "\xE2\x80\xA2", "\x96" => "\xE2\x80\x93", "\x97" => "\xE2\x80\x94", "\x98" => "\xCB\x9C", "\x99" => "\xE2\x84\xA2", "\x9A" => "\xC5\xA1", "\x9B" => "\xE2\x80\xBA", "\x9C" => "\xC5\x93", "\x9D" => "\xEF\xBF\xBD", "\x9E" => "\xC5\xBE", "\x9F" => "\xC5\xB8", "\xA0" => "\xC2\xA0", "\xA1" => "\xC2\xA1", "\xA2" => "\xC2\xA2", "\xA3" => "\xC2\xA3", "\xA4" => "\xC2\xA4", "\xA5" => "\xC2\xA5", "\xA6" => "\xC2\xA6", "\xA7" => "\xC2\xA7", "\xA8" => "\xC2\xA8", "\xA9" => "\xC2\xA9", "\xAA" => "\xC2\xAA", "\xAB" => "\xC2\xAB", "\xAC" => "\xC2\xAC", "\xAD" => "\xC2\xAD", "\xAE" => "\xC2\xAE", "\xAF" => "\xC2\xAF", "\xB0" => "\xC2\xB0", "\xB1" => "\xC2\xB1", "\xB2" => "\xC2\xB2", "\xB3" => "\xC2\xB3", "\xB4" => "\xC2\xB4", "\xB5" => "\xC2\xB5", "\xB6" => "\xC2\xB6", "\xB7" => "\xC2\xB7", "\xB8" => "\xC2\xB8", "\xB9" => "\xC2\xB9", "\xBA" => "\xC2\xBA", "\xBB" => "\xC2\xBB", "\xBC" => "\xC2\xBC", "\xBD" => "\xC2\xBD", "\xBE" => "\xC2\xBE", "\xBF" => "\xC2\xBF", "\xC0" => "\xC3\x80", "\xC1" => "\xC3\x81", "\xC2" => "\xC3\x82", "\xC3" => "\xC3\x83", "\xC4" => "\xC3\x84", "\xC5" => "\xC3\x85", "\xC6" => "\xC3\x86", "\xC7" => "\xC3\x87", "\xC8" => "\xC3\x88", "\xC9" => "\xC3\x89", "\xCA" => "\xC3\x8A", "\xCB" => "\xC3\x8B", "\xCC" => "\xC3\x8C", "\xCD" => "\xC3\x8D", "\xCE" => "\xC3\x8E", "\xCF" => "\xC3\x8F", "\xD0" => "\xC3\x90", "\xD1" => "\xC3\x91", "\xD2" => "\xC3\x92", "\xD3" => "\xC3\x93", "\xD4" => "\xC3\x94", "\xD5" => "\xC3\x95", "\xD6" => "\xC3\x96", "\xD7" => "\xC3\x97", "\xD8" => "\xC3\x98", "\xD9" => "\xC3\x99", "\xDA" => "\xC3\x9A", "\xDB" => "\xC3\x9B", "\xDC" => "\xC3\x9C", "\xDD" => "\xC3\x9D", "\xDE" => "\xC3\x9E", "\xDF" => "\xC3\x9F", "\xE0" => "\xC3\xA0", "\xE1" => "\xC3\xA1", "\xE2" => "\xC3\xA2", "\xE3" => "\xC3\xA3", "\xE4" => "\xC3\xA4", "\xE5" => "\xC3\xA5", "\xE6" => "\xC3\xA6", "\xE7" => "\xC3\xA7", "\xE8" => "\xC3\xA8", "\xE9" => "\xC3\xA9", "\xEA" => "\xC3\xAA", "\xEB" => "\xC3\xAB", "\xEC" => "\xC3\xAC", "\xED" => "\xC3\xAD", "\xEE" => "\xC3\xAE", "\xEF" => "\xC3\xAF", "\xF0" => "\xC3\xB0", "\xF1" => "\xC3\xB1", "\xF2" => "\xC3\xB2", "\xF3" => "\xC3\xB3", "\xF4" => "\xC3\xB4", "\xF5" => "\xC3\xB5", "\xF6" => "\xC3\xB6", "\xF7" => "\xC3\xB7", "\xF8" => "\xC3\xB8", "\xF9" => "\xC3\xB9", "\xFA" => "\xC3\xBA", "\xFB" => "\xC3\xBB", "\xFC" => "\xC3\xBC", "\xFD" => "\xC3\xBD", "\xFE" => "\xC3\xBE", "\xFF" => "\xC3\xBF");
 275: 
 276:         return strtr($string, $convert_table);
 277:     }
 278: 
 279:     /**
 280:      * Change a string from one encoding to another
 281:      *
 282:      * @param string $data Raw data in $input encoding
 283:      * @param string $input Encoding of $data
 284:      * @param string $output Encoding you want
 285:      * @return string|boolean False if we can't convert it
 286:      */
 287:     public static function change_encoding($data, $input, $output)
 288:     {
 289:         $input = SimplePie_Misc::encoding($input);
 290:         $output = SimplePie_Misc::encoding($output);
 291: 
 292:         // We fail to fail on non US-ASCII bytes
 293:         if ($input === 'US-ASCII')
 294:         {
 295:             static $non_ascii_octects = '';
 296:             if (!$non_ascii_octects)
 297:             {
 298:                 for ($i = 0x80; $i <= 0xFF; $i++)
 299:                 {
 300:                     $non_ascii_octects .= chr($i);
 301:                 }
 302:             }
 303:             $data = substr($data, 0, strcspn($data, $non_ascii_octects));
 304:         }
 305: 
 306:         // This is first, as behaviour of this is completely predictable
 307:         if ($input === 'windows-1252' && $output === 'UTF-8')
 308:         {
 309:             return SimplePie_Misc::windows_1252_to_utf8($data);
 310:         }
 311:         // This is second, as behaviour of this varies only with PHP version (the middle part of this expression checks the encoding is supported).
 312:         elseif (function_exists('mb_convert_encoding') && ($return = SimplePie_Misc::change_encoding_mbstring($data, $input, $output)))
 313:         {
 314:             return $return;
 315:         }
 316:         // This is last, as behaviour of this varies with OS userland and PHP version
 317:         elseif (function_exists('iconv') && ($return = SimplePie_Misc::change_encoding_iconv($data, $input, $output)))
 318:         {
 319:             return $return;
 320:         }
 321:         // If we can't do anything, just fail
 322:         else
 323:         {
 324:             return false;
 325:         }
 326:     }
 327: 
 328:     protected static function change_encoding_mbstring($data, $input, $output)
 329:     {
 330:         if ($input === 'windows-949')
 331:         {
 332:             $input = 'EUC-KR';
 333:         }
 334:         if ($output === 'windows-949')
 335:         {
 336:             $output = 'EUC-KR';
 337:         }
 338:         if ($input === 'Windows-31J')
 339:         {
 340:             $input = 'SJIS';
 341:         }
 342:         if ($output === 'Windows-31J')
 343:         {
 344:             $output = 'SJIS';
 345:         }
 346: 
 347:         // Check that the encoding is supported
 348:         if (@mb_convert_encoding("\x80", 'UTF-16BE', $input) === "\x00\x80")
 349:         {
 350:             return false;
 351:         }
 352:         if (!in_array($input, mb_list_encodings()))
 353:         {
 354:             return false;
 355:         }
 356: 
 357:         // Let's do some conversion
 358:         if ($return = @mb_convert_encoding($data, $output, $input))
 359:         {
 360:             return $return;
 361:         }
 362: 
 363:         return false;
 364:     }
 365: 
 366:     protected static function change_encoding_iconv($data, $input, $output)
 367:     {
 368:         return @iconv($input, $output, $data);
 369:     }
 370: 
 371:     /**
 372:      * Normalize an encoding name
 373:      *
 374:      * This is automatically generated by create.php
 375:      *
 376:      * To generate it, run `php create.php` on the command line, and copy the
 377:      * output to replace this function.
 378:      *
 379:      * @param string $charset Character set to standardise
 380:      * @return string Standardised name
 381:      */
 382:     public static function encoding($charset)
 383:     {
 384:         // Normalization from UTS #22
 385:         switch (strtolower(preg_replace('/(?:[^a-zA-Z0-9]+|([^0-9])0+)/', '\1', $charset)))
 386:         {
 387:             case 'adobestandardencoding':
 388:             case 'csadobestandardencoding':
 389:                 return 'Adobe-Standard-Encoding';
 390: 
 391:             case 'adobesymbolencoding':
 392:             case 'cshppsmath':
 393:                 return 'Adobe-Symbol-Encoding';
 394: 
 395:             case 'ami1251':
 396:             case 'amiga1251':
 397:                 return 'Amiga-1251';
 398: 
 399:             case 'ansix31101983':
 400:             case 'csat5001983':
 401:             case 'csiso99naplps':
 402:             case 'isoir99':
 403:             case 'naplps':
 404:                 return 'ANSI_X3.110-1983';
 405: 
 406:             case 'arabic7':
 407:             case 'asmo449':
 408:             case 'csiso89asmo449':
 409:             case 'iso9036':
 410:             case 'isoir89':
 411:                 return 'ASMO_449';
 412: 
 413:             case 'big5':
 414:             case 'csbig5':
 415:                 return 'Big5';
 416: 
 417:             case 'big5hkscs':
 418:                 return 'Big5-HKSCS';
 419: 
 420:             case 'bocu1':
 421:             case 'csbocu1':
 422:                 return 'BOCU-1';
 423: 
 424:             case 'brf':
 425:             case 'csbrf':
 426:                 return 'BRF';
 427: 
 428:             case 'bs4730':
 429:             case 'csiso4unitedkingdom':
 430:             case 'gb':
 431:             case 'iso646gb':
 432:             case 'isoir4':
 433:             case 'uk':
 434:                 return 'BS_4730';
 435: 
 436:             case 'bsviewdata':
 437:             case 'csiso47bsviewdata':
 438:             case 'isoir47':
 439:                 return 'BS_viewdata';
 440: 
 441:             case 'cesu8':
 442:             case 'cscesu8':
 443:                 return 'CESU-8';
 444: 
 445:             case 'ca':
 446:             case 'csa71':
 447:             case 'csaz243419851':
 448:             case 'csiso121canadian1':
 449:             case 'iso646ca':
 450:             case 'isoir121':
 451:                 return 'CSA_Z243.4-1985-1';
 452: 
 453:             case 'csa72':
 454:             case 'csaz243419852':
 455:             case 'csiso122canadian2':
 456:             case 'iso646ca2':
 457:             case 'isoir122':
 458:                 return 'CSA_Z243.4-1985-2';
 459: 
 460:             case 'csaz24341985gr':
 461:             case 'csiso123csaz24341985gr':
 462:             case 'isoir123':
 463:                 return 'CSA_Z243.4-1985-gr';
 464: 
 465:             case 'csiso139csn369103':
 466:             case 'csn369103':
 467:             case 'isoir139':
 468:                 return 'CSN_369103';
 469: 
 470:             case 'csdecmcs':
 471:             case 'dec':
 472:             case 'decmcs':
 473:                 return 'DEC-MCS';
 474: 
 475:             case 'csiso21german':
 476:             case 'de':
 477:             case 'din66003':
 478:             case 'iso646de':
 479:             case 'isoir21':
 480:                 return 'DIN_66003';
 481: 
 482:             case 'csdkus':
 483:             case 'dkus':
 484:                 return 'dk-us';
 485: 
 486:             case 'csiso646danish':
 487:             case 'dk':
 488:             case 'ds2089':
 489:             case 'iso646dk':
 490:                 return 'DS_2089';
 491: 
 492:             case 'csibmebcdicatde':
 493:             case 'ebcdicatde':
 494:                 return 'EBCDIC-AT-DE';
 495: 
 496:             case 'csebcdicatdea':
 497:             case 'ebcdicatdea':
 498:                 return 'EBCDIC-AT-DE-A';
 499: 
 500:             case 'csebcdiccafr':
 501:             case 'ebcdiccafr':
 502:                 return 'EBCDIC-CA-FR';
 503: 
 504:             case 'csebcdicdkno':
 505:             case 'ebcdicdkno':
 506:                 return 'EBCDIC-DK-NO';
 507: 
 508:             case 'csebcdicdknoa':
 509:             case 'ebcdicdknoa':
 510:                 return 'EBCDIC-DK-NO-A';
 511: 
 512:             case 'csebcdices':
 513:             case 'ebcdices':
 514:                 return 'EBCDIC-ES';
 515: 
 516:             case 'csebcdicesa':
 517:             case 'ebcdicesa':
 518:                 return 'EBCDIC-ES-A';
 519: 
 520:             case 'csebcdicess':
 521:             case 'ebcdicess':
 522:                 return 'EBCDIC-ES-S';
 523: 
 524:             case 'csebcdicfise':
 525:             case 'ebcdicfise':
 526:                 return 'EBCDIC-FI-SE';
 527: 
 528:             case 'csebcdicfisea':
 529:             case 'ebcdicfisea':
 530:                 return 'EBCDIC-FI-SE-A';
 531: 
 532:             case 'csebcdicfr':
 533:             case 'ebcdicfr':
 534:                 return 'EBCDIC-FR';
 535: 
 536:             case 'csebcdicit':
 537:             case 'ebcdicit':
 538:                 return 'EBCDIC-IT';
 539: 
 540:             case 'csebcdicpt':
 541:             case 'ebcdicpt':
 542:                 return 'EBCDIC-PT';
 543: 
 544:             case 'csebcdicuk':
 545:             case 'ebcdicuk':
 546:                 return 'EBCDIC-UK';
 547: 
 548:             case 'csebcdicus':
 549:             case 'ebcdicus':
 550:                 return 'EBCDIC-US';
 551: 
 552:             case 'csiso111ecmacyrillic':
 553:             case 'ecmacyrillic':
 554:             case 'isoir111':
 555:             case 'koi8e':
 556:                 return 'ECMA-cyrillic';
 557: 
 558:             case 'csiso17spanish':
 559:             case 'es':
 560:             case 'iso646es':
 561:             case 'isoir17':
 562:                 return 'ES';
 563: 
 564:             case 'csiso85spanish2':
 565:             case 'es2':
 566:             case 'iso646es2':
 567:             case 'isoir85':
 568:                 return 'ES2';
 569: 
 570:             case 'cseucpkdfmtjapanese':
 571:             case 'eucjp':
 572:             case 'extendedunixcodepackedformatforjapanese':
 573:                 return 'EUC-JP';
 574: 
 575:             case 'cseucfixwidjapanese':
 576:             case 'extendedunixcodefixedwidthforjapanese':
 577:                 return 'Extended_UNIX_Code_Fixed_Width_for_Japanese';
 578: 
 579:             case 'gb18030':
 580:                 return 'GB18030';
 581: 
 582:             case 'chinese':
 583:             case 'cp936':
 584:             case 'csgb2312':
 585:             case 'csiso58gb231280':
 586:             case 'gb2312':
 587:             case 'gb231280':
 588:             case 'gbk':
 589:             case 'isoir58':
 590:             case 'ms936':
 591:             case 'windows936':
 592:                 return 'GBK';
 593: 
 594:             case 'cn':
 595:             case 'csiso57gb1988':
 596:             case 'gb198880':
 597:             case 'iso646cn':
 598:             case 'isoir57':
 599:                 return 'GB_1988-80';
 600: 
 601:             case 'csiso153gost1976874':
 602:             case 'gost1976874':
 603:             case 'isoir153':
 604:             case 'stsev35888':
 605:                 return 'GOST_19768-74';
 606: 
 607:             case 'csiso150':
 608:             case 'csiso150greekccitt':
 609:             case 'greekccitt':
 610:             case 'isoir150':
 611:                 return 'greek-ccitt';
 612: 
 613:             case 'csiso88greek7':
 614:             case 'greek7':
 615:             case 'isoir88':
 616:                 return 'greek7';
 617: 
 618:             case 'csiso18greek7old':
 619:             case 'greek7old':
 620:             case 'isoir18':
 621:                 return 'greek7-old';
 622: 
 623:             case 'cshpdesktop':
 624:             case 'hpdesktop':
 625:                 return 'HP-DeskTop';
 626: 
 627:             case 'cshplegal':
 628:             case 'hplegal':
 629:                 return 'HP-Legal';
 630: 
 631:             case 'cshpmath8':
 632:             case 'hpmath8':
 633:                 return 'HP-Math8';
 634: 
 635:             case 'cshppifont':
 636:             case 'hppifont':
 637:                 return 'HP-Pi-font';
 638: 
 639:             case 'cshproman8':
 640:             case 'hproman8':
 641:             case 'r8':
 642:             case 'roman8':
 643:                 return 'hp-roman8';
 644: 
 645:             case 'hzgb2312':
 646:                 return 'HZ-GB-2312';
 647: 
 648:             case 'csibmsymbols':
 649:             case 'ibmsymbols':
 650:                 return 'IBM-Symbols';
 651: 
 652:             case 'csibmthai':
 653:             case 'ibmthai':
 654:                 return 'IBM-Thai';
 655: 
 656:             case 'cp37':
 657:             case 'csibm37':
 658:             case 'ebcdiccpca':
 659:             case 'ebcdiccpnl':
 660:             case 'ebcdiccpus':
 661:             case 'ebcdiccpwt':
 662:             case 'ibm37':
 663:                 return 'IBM037';
 664: 
 665:             case 'cp38':
 666:             case 'csibm38':
 667:             case 'ebcdicint':
 668:             case 'ibm38':
 669:                 return 'IBM038';
 670: 
 671:             case 'cp273':
 672:             case 'csibm273':
 673:             case 'ibm273':
 674:                 return 'IBM273';
 675: 
 676:             case 'cp274':
 677:             case 'csibm274':
 678:             case 'ebcdicbe':
 679:             case 'ibm274':
 680:                 return 'IBM274';
 681: 
 682:             case 'cp275':
 683:             case 'csibm275':
 684:             case 'ebcdicbr':
 685:             case 'ibm275':
 686:                 return 'IBM275';
 687: 
 688:             case 'csibm277':
 689:             case 'ebcdiccpdk':
 690:             case 'ebcdiccpno':
 691:             case 'ibm277':
 692:                 return 'IBM277';
 693: 
 694:             case 'cp278':
 695:             case 'csibm278':
 696:             case 'ebcdiccpfi':
 697:             case 'ebcdiccpse':
 698:             case 'ibm278':
 699:                 return 'IBM278';
 700: 
 701:             case 'cp280':
 702:             case 'csibm280':
 703:             case 'ebcdiccpit':
 704:             case 'ibm280':
 705:                 return 'IBM280';
 706: 
 707:             case 'cp281':
 708:             case 'csibm281':
 709:             case 'ebcdicjpe':
 710:             case 'ibm281':
 711:                 return 'IBM281';
 712: 
 713:             case 'cp284':
 714:             case 'csibm284':
 715:             case 'ebcdiccpes':
 716:             case 'ibm284':
 717:                 return 'IBM284';
 718: 
 719:             case 'cp285':
 720:             case 'csibm285':
 721:             case 'ebcdiccpgb':
 722:             case 'ibm285':
 723:                 return 'IBM285';
 724: 
 725:             case 'cp290':
 726:             case 'csibm290':
 727:             case 'ebcdicjpkana':
 728:             case 'ibm290':
 729:                 return 'IBM290';
 730: 
 731:             case 'cp297':
 732:             case 'csibm297':
 733:             case 'ebcdiccpfr':
 734:             case 'ibm297':
 735:                 return 'IBM297';
 736: 
 737:             case 'cp420':
 738:             case 'csibm420':
 739:             case 'ebcdiccpar1':
 740:             case 'ibm420':
 741:                 return 'IBM420';
 742: 
 743:             case 'cp423':
 744:             case 'csibm423':
 745:             case 'ebcdiccpgr':
 746:             case 'ibm423':
 747:                 return 'IBM423';
 748: 
 749:             case 'cp424':
 750:             case 'csibm424':
 751:             case 'ebcdiccphe':
 752:             case 'ibm424':
 753:                 return 'IBM424';
 754: 
 755:             case '437':
 756:             case 'cp437':
 757:             case 'cspc8codepage437':
 758:             case 'ibm437':
 759:                 return 'IBM437';
 760: 
 761:             case 'cp500':
 762:             case 'csibm500':
 763:             case 'ebcdiccpbe':
 764:             case 'ebcdiccpch':
 765:             case 'ibm500':
 766:                 return 'IBM500';
 767: 
 768:             case 'cp775':
 769:             case 'cspc775baltic':
 770:             case 'ibm775':
 771:                 return 'IBM775';
 772: 
 773:             case '850':
 774:             case 'cp850':
 775:             case 'cspc850multilingual':
 776:             case 'ibm850':
 777:                 return 'IBM850';
 778: 
 779:             case '851':
 780:             case 'cp851':
 781:             case 'csibm851':
 782:             case 'ibm851':
 783:                 return 'IBM851';
 784: 
 785:             case '852':
 786:             case 'cp852':
 787:             case 'cspcp852':
 788:             case 'ibm852':
 789:                 return 'IBM852';
 790: 
 791:             case '855':
 792:             case 'cp855':
 793:             case 'csibm855':
 794:             case 'ibm855':
 795:                 return 'IBM855';
 796: 
 797:             case '857':
 798:             case 'cp857':
 799:             case 'csibm857':
 800:             case 'ibm857':
 801:                 return 'IBM857';
 802: 
 803:             case 'ccsid858':
 804:             case 'cp858':
 805:             case 'ibm858':
 806:             case 'pcmultilingual850euro':
 807:                 return 'IBM00858';
 808: 
 809:             case '860':
 810:             case 'cp860':
 811:             case 'csibm860':
 812:             case 'ibm860':
 813:                 return 'IBM860';
 814: 
 815:             case '861':
 816:             case 'cp861':
 817:             case 'cpis':
 818:             case 'csibm861':
 819:             case 'ibm861':
 820:                 return 'IBM861';
 821: 
 822:             case '862':
 823:             case 'cp862':
 824:             case 'cspc862latinhebrew':
 825:             case 'ibm862':
 826:                 return 'IBM862';
 827: 
 828:             case '863':
 829:             case 'cp863':
 830:             case 'csibm863':
 831:             case 'ibm863':
 832:                 return 'IBM863';
 833: 
 834:             case 'cp864':
 835:             case 'csibm864':
 836:             case 'ibm864':
 837:                 return 'IBM864';
 838: 
 839:             case '865':
 840:             case 'cp865':
 841:             case 'csibm865':
 842:             case 'ibm865':
 843:                 return 'IBM865';
 844: 
 845:             case '866':
 846:             case 'cp866':
 847:             case 'csibm866':
 848:             case 'ibm866':
 849:                 return 'IBM866';
 850: 
 851:             case 'cp868':
 852:             case 'cpar':
 853:             case 'csibm868':
 854:             case 'ibm868':
 855:                 return 'IBM868';
 856: 
 857:             case '869':
 858:             case 'cp869':
 859:             case 'cpgr':
 860:             case 'csibm869':
 861:             case 'ibm869':
 862:                 return 'IBM869';
 863: 
 864:             case 'cp870':
 865:             case 'csibm870':
 866:             case 'ebcdiccproece':
 867:             case 'ebcdiccpyu':
 868:             case 'ibm870':
 869:                 return 'IBM870';
 870: 
 871:             case 'cp871':
 872:             case 'csibm871':
 873:             case 'ebcdiccpis':
 874:             case 'ibm871':
 875:                 return 'IBM871';
 876: 
 877:             case 'cp880':
 878:             case 'csibm880':
 879:             case 'ebcdiccyrillic':
 880:             case 'ibm880':
 881:                 return 'IBM880';
 882: 
 883:             case 'cp891':
 884:             case 'csibm891':
 885:             case 'ibm891':
 886:                 return 'IBM891';
 887: 
 888:             case 'cp903':
 889:             case 'csibm903':
 890:             case 'ibm903':
 891:                 return 'IBM903';
 892: 
 893:             case '904':
 894:             case 'cp904':
 895:             case 'csibbm904':
 896:             case 'ibm904':
 897:                 return 'IBM904';
 898: 
 899:             case 'cp905':
 900:             case 'csibm905':
 901:             case 'ebcdiccptr':
 902:             case 'ibm905':
 903:                 return 'IBM905';
 904: 
 905:             case 'cp918':
 906:             case 'csibm918':
 907:             case 'ebcdiccpar2':
 908:             case 'ibm918':
 909:                 return 'IBM918';
 910: 
 911:             case 'ccsid924':
 912:             case 'cp924':
 913:             case 'ebcdiclatin9euro':
 914:             case 'ibm924':
 915:                 return 'IBM00924';
 916: 
 917:             case 'cp1026':
 918:             case 'csibm1026':
 919:             case 'ibm1026':
 920:                 return 'IBM1026';
 921: 
 922:             case 'ibm1047':
 923:                 return 'IBM1047';
 924: 
 925:             case 'ccsid1140':
 926:             case 'cp1140':
 927:             case 'ebcdicus37euro':
 928:             case 'ibm1140':
 929:                 return 'IBM01140';
 930: 
 931:             case 'ccsid1141':
 932:             case 'cp1141':
 933:             case 'ebcdicde273euro':
 934:             case 'ibm1141':
 935:                 return 'IBM01141';
 936: 
 937:             case 'ccsid1142':
 938:             case 'cp1142':
 939:             case 'ebcdicdk277euro':
 940:             case 'ebcdicno277euro':
 941:             case 'ibm1142':
 942:                 return 'IBM01142';
 943: 
 944:             case 'ccsid1143':
 945:             case 'cp1143':
 946:             case 'ebcdicfi278euro':
 947:             case 'ebcdicse278euro':
 948:             case 'ibm1143':
 949:                 return 'IBM01143';
 950: 
 951:             case 'ccsid1144':
 952:             case 'cp1144':
 953:             case 'ebcdicit280euro':
 954:             case 'ibm1144':
 955:                 return 'IBM01144';
 956: 
 957:             case 'ccsid1145':
 958:             case 'cp1145':
 959:             case 'ebcdices284euro':
 960:             case 'ibm1145':
 961:                 return 'IBM01145';
 962: 
 963:             case 'ccsid1146':
 964:             case 'cp1146':
 965:             case 'ebcdicgb285euro':
 966:             case 'ibm1146':
 967:                 return 'IBM01146';
 968: 
 969:             case 'ccsid1147':
 970:             case 'cp1147':
 971:             case 'ebcdicfr297euro':
 972:             case 'ibm1147':
 973:                 return 'IBM01147';
 974: 
 975:             case 'ccsid1148':
 976:             case 'cp1148':
 977:             case 'ebcdicinternational500euro':
 978:             case 'ibm1148':
 979:                 return 'IBM01148';
 980: 
 981:             case 'ccsid1149':
 982:             case 'cp1149':
 983:             case 'ebcdicis871euro':
 984:             case 'ibm1149':
 985:                 return 'IBM01149';
 986: 
 987:             case 'csiso143iecp271':
 988:             case 'iecp271':
 989:             case 'isoir143':
 990:                 return 'IEC_P27-1';
 991: 
 992:             case 'csiso49inis':
 993:             case 'inis':
 994:             case 'isoir49':
 995:                 return 'INIS';
 996: 
 997:             case 'csiso50inis8':
 998:             case 'inis8':
 999:             case 'isoir50':
1000:                 return 'INIS-8';
1001: 
1002:             case 'csiso51iniscyrillic':
1003:             case 'iniscyrillic':
1004:             case 'isoir51':
1005:                 return 'INIS-cyrillic';
1006: 
1007:             case 'csinvariant':
1008:             case 'invariant':
1009:                 return 'INVARIANT';
1010: 
1011:             case 'iso2022cn':
1012:                 return 'ISO-2022-CN';
1013: 
1014:             case 'iso2022cnext':
1015:                 return 'ISO-2022-CN-EXT';
1016: 
1017:             case 'csiso2022jp':
1018:             case 'iso2022jp':
1019:                 return 'ISO-2022-JP';
1020: 
1021:             case 'csiso2022jp2':
1022:             case 'iso2022jp2':
1023:                 return 'ISO-2022-JP-2';
1024: 
1025:             case 'csiso2022kr':
1026:             case 'iso2022kr':
1027:                 return 'ISO-2022-KR';
1028: 
1029:             case 'cswindows30latin1':
1030:             case 'iso88591windows30latin1':
1031:                 return 'ISO-8859-1-Windows-3.0-Latin-1';
1032: 
1033:             case 'cswindows31latin1':
1034:             case 'iso88591windows31latin1':
1035:                 return 'ISO-8859-1-Windows-3.1-Latin-1';
1036: 
1037:             case 'csisolatin2':
1038:             case 'iso88592':
1039:             case 'iso885921987':
1040:             case 'isoir101':
1041:             case 'l2':
1042:             case 'latin2':
1043:                 return 'ISO-8859-2';
1044: 
1045:             case 'cswindows31latin2':
1046:             case 'iso88592windowslatin2':
1047:                 return 'ISO-8859-2-Windows-Latin-2';
1048: 
1049:             case 'csisolatin3':
1050:             case 'iso88593':
1051:             case 'iso885931988':
1052:             case 'isoir109':
1053:             case 'l3':
1054:             case 'latin3':
1055:                 return 'ISO-8859-3';
1056: 
1057:             case 'csisolatin4':
1058:             case 'iso88594':
1059:             case 'iso885941988':
1060:             case 'isoir110':
1061:             case 'l4':
1062:             case 'latin4':
1063:                 return 'ISO-8859-4';
1064: 
1065:             case 'csisolatincyrillic':
1066:             case 'cyrillic':
1067:             case 'iso88595':
1068:             case 'iso885951988':
1069:             case 'isoir144':
1070:                 return 'ISO-8859-5';
1071: 
1072:             case 'arabic':
1073:             case 'asmo708':
1074:             case 'csisolatinarabic':
1075:             case 'ecma114':
1076:             case 'iso88596':
1077:             case 'iso885961987':
1078:             case 'isoir127':
1079:                 return 'ISO-8859-6';
1080: 
1081:             case 'csiso88596e':
1082:             case 'iso88596e':
1083:                 return 'ISO-8859-6-E';
1084: 
1085:             case 'csiso88596i':
1086:             case 'iso88596i':
1087:                 return 'ISO-8859-6-I';
1088: 
1089:             case 'csisolatingreek':
1090:             case 'ecma118':
1091:             case 'elot928':
1092:             case 'greek':
1093:             case 'greek8':
1094:             case 'iso88597':
1095:             case 'iso885971987':
1096:             case 'isoir126':
1097:                 return 'ISO-8859-7';
1098: 
1099:             case 'csisolatinhebrew':
1100:             case 'hebrew':
1101:             case 'iso88598':
1102:             case 'iso885981988':
1103:             case 'isoir138':
1104:                 return 'ISO-8859-8';
1105: 
1106:             case 'csiso88598e':
1107:             case 'iso88598e':
1108:                 return 'ISO-8859-8-E';
1109: 
1110:             case 'csiso88598i':
1111:             case 'iso88598i':
1112:                 return 'ISO-8859-8-I';
1113: 
1114:             case 'cswindows31latin5':
1115:             case 'iso88599windowslatin5':
1116:                 return 'ISO-8859-9-Windows-Latin-5';
1117: 
1118:             case 'csisolatin6':
1119:             case 'iso885910':
1120:             case 'iso8859101992':
1121:             case 'isoir157':
1122:             case 'l6':
1123:             case 'latin6':
1124:                 return 'ISO-8859-10';
1125: 
1126:             case 'iso885913':
1127:                 return 'ISO-8859-13';
1128: 
1129:             case 'iso885914':
1130:             case 'iso8859141998':
1131:             case 'isoceltic':
1132:             case 'isoir199':
1133:             case 'l8':
1134:             case 'latin8':
1135:                 return 'ISO-8859-14';
1136: 
1137:             case 'iso885915':
1138:             case 'latin9':
1139:                 return 'ISO-8859-15';
1140: 
1141:             case 'iso885916':
1142:             case 'iso8859162001':
1143:             case 'isoir226':
1144:             case 'l10':
1145:             case 'latin10':
1146:                 return 'ISO-8859-16';
1147: 
1148:             case 'iso10646j1':
1149:                 return 'ISO-10646-J-1';
1150: 
1151:             case 'csunicode':
1152:             case 'iso10646ucs2':
1153:                 return 'ISO-10646-UCS-2';
1154: 
1155:             case 'csucs4':
1156:             case 'iso10646ucs4':
1157:                 return 'ISO-10646-UCS-4';
1158: 
1159:             case 'csunicodeascii':
1160:             case 'iso10646ucsbasic':
1161:                 return 'ISO-10646-UCS-Basic';
1162: 
1163:             case 'csunicodelatin1':
1164:             case 'iso10646':
1165:             case 'iso10646unicodelatin1':
1166:                 return 'ISO-10646-Unicode-Latin1';
1167: 
1168:             case 'csiso10646utf1':
1169:             case 'iso10646utf1':
1170:                 return 'ISO-10646-UTF-1';
1171: 
1172:             case 'csiso115481':
1173:             case 'iso115481':
1174:             case 'isotr115481':
1175:                 return 'ISO-11548-1';
1176: 
1177:             case 'csiso90':
1178:             case 'isoir90':
1179:                 return 'iso-ir-90';
1180: 
1181:             case 'csunicodeibm1261':
1182:             case 'isounicodeibm1261':
1183:                 return 'ISO-Unicode-IBM-1261';
1184: 
1185:             case 'csunicodeibm1264':
1186:             case 'isounicodeibm1264':
1187:                 return 'ISO-Unicode-IBM-1264';
1188: 
1189:             case 'csunicodeibm1265':
1190:             case 'isounicodeibm1265':
1191:                 return 'ISO-Unicode-IBM-1265';
1192: 
1193:             case 'csunicodeibm1268':
1194:             case 'isounicodeibm1268':
1195:                 return 'ISO-Unicode-IBM-1268';
1196: 
1197:             case 'csunicodeibm1276':
1198:             case 'isounicodeibm1276':
1199:                 return 'ISO-Unicode-IBM-1276';
1200: 
1201:             case 'csiso646basic1983':
1202:             case 'iso646basic1983':
1203:             case 'ref':
1204:                 return 'ISO_646.basic:1983';
1205: 
1206:             case 'csiso2intlrefversion':
1207:             case 'irv':
1208:             case 'iso646irv1983':
1209:             case 'isoir2':
1210:                 return 'ISO_646.irv:1983';
1211: 
1212:             case 'csiso2033':
1213:             case 'e13b':
1214:             case 'iso20331983':
1215:             case 'isoir98':
1216:                 return 'ISO_2033-1983';
1217: 
1218:             case 'csiso5427cyrillic':
1219:             case 'iso5427':
1220:             case 'isoir37':
1221:                 return 'ISO_5427';
1222: 
1223:             case 'iso5427cyrillic1981':
1224:             case 'iso54271981':
1225:             case 'isoir54':
1226:                 return 'ISO_5427:1981';
1227: 
1228:             case 'csiso5428greek':
1229:             case 'iso54281980':
1230:             case 'isoir55':
1231:                 return 'ISO_5428:1980';
1232: 
1233:             case 'csiso6937add':
1234:             case 'iso6937225':
1235:             case 'isoir152':
1236:                 return 'ISO_6937-2-25';
1237: 
1238:             case 'csisotextcomm':
1239:             case 'iso69372add':
1240:             case 'isoir142':
1241:                 return 'ISO_6937-2-add';
1242: 
1243:             case 'csiso8859supp':
1244:             case 'iso8859supp':
1245:             case 'isoir154':
1246:             case 'latin125':
1247:                 return 'ISO_8859-supp';
1248: 
1249:             case 'csiso10367box':
1250:             case 'iso10367box':
1251:             case 'isoir155':
1252:                 return 'ISO_10367-box';
1253: 
1254:             case 'csiso15italian':
1255:             case 'iso646it':
1256:             case 'isoir15':
1257:             case 'it':
1258:                 return 'IT';
1259: 
1260:             case 'csiso13jisc6220jp':
1261:             case 'isoir13':
1262:             case 'jisc62201969':
1263:             case 'jisc62201969jp':
1264:             case 'katakana':
1265:             case 'x2017':
1266:                 return 'JIS_C6220-1969-jp';
1267: 
1268:             case 'csiso14jisc6220ro':
1269:             case 'iso646jp':
1270:             case 'isoir14':
1271:             case 'jisc62201969ro':
1272:             case 'jp':
1273:                 return 'JIS_C6220-1969-ro';
1274: 
1275:             case 'csiso42jisc62261978':
1276:             case 'isoir42':
1277:             case 'jisc62261978':
1278:                 return 'JIS_C6226-1978';
1279: 
1280:             case 'csiso87jisx208':
1281:             case 'isoir87':
1282:             case 'jisc62261983':
1283:             case 'jisx2081983':
1284:             case 'x208':
1285:                 return 'JIS_C6226-1983';
1286: 
1287:             case 'csiso91jisc62291984a':
1288:             case 'isoir91':
1289:             case 'jisc62291984a':
1290:             case 'jpocra':
1291:                 return 'JIS_C6229-1984-a';
1292: 
1293:             case 'csiso92jisc62991984b':
1294:             case 'iso646jpocrb':
1295:             case 'isoir92':
1296:             case 'jisc62291984b':
1297:             case 'jpocrb':
1298:                 return 'JIS_C6229-1984-b';
1299: 
1300:             case 'csiso93jis62291984badd':
1301:             case 'isoir93':
1302:             case 'jisc62291984badd':
1303:             case 'jpocrbadd':
1304:                 return 'JIS_C6229-1984-b-add';
1305: 
1306:             case 'csiso94jis62291984hand':
1307:             case 'isoir94':
1308:             case 'jisc62291984hand':
1309:             case 'jpocrhand':
1310:                 return 'JIS_C6229-1984-hand';
1311: 
1312:             case 'csiso95jis62291984handadd':
1313:             case 'isoir95':
1314:             case 'jisc62291984handadd':
1315:             case 'jpocrhandadd':
1316:                 return 'JIS_C6229-1984-hand-add';
1317: 
1318:             case 'csiso96jisc62291984kana':
1319:             case 'isoir96':
1320:             case 'jisc62291984kana':
1321:                 return 'JIS_C6229-1984-kana';
1322: 
1323:             case 'csjisencoding':
1324:             case 'jisencoding':
1325:                 return 'JIS_Encoding';
1326: 
1327:             case 'cshalfwidthkatakana':
1328:             case 'jisx201':
1329:             case 'x201':
1330:                 return 'JIS_X0201';
1331: 
1332:             case 'csiso159jisx2121990':
1333:             case 'isoir159':
1334:             case 'jisx2121990':
1335:             case 'x212':
1336:                 return 'JIS_X0212-1990';
1337: 
1338:             case 'csiso141jusib1002':
1339:             case 'iso646yu':
1340:             case 'isoir141':
1341:             case 'js':
1342:             case 'jusib1002':
1343:             case 'yu':
1344:                 return 'JUS_I.B1.002';
1345: 
1346:             case 'csiso147macedonian':
1347:             case 'isoir147':
1348:             case 'jusib1003mac':
1349:             case 'macedonian':
1350:                 return 'JUS_I.B1.003-mac';
1351: 
1352:             case 'csiso146serbian':
1353:             case 'isoir146':
1354:             case 'jusib1003serb':
1355:             case 'serbian':
1356:                 return 'JUS_I.B1.003-serb';
1357: 
1358:             case 'koi7switched':
1359:                 return 'KOI7-switched';
1360: 
1361:             case 'cskoi8r':
1362:             case 'koi8r':
1363:                 return 'KOI8-R';
1364: 
1365:             case 'koi8u':
1366:                 return 'KOI8-U';
1367: 
1368:             case 'csksc5636':
1369:             case 'iso646kr':
1370:             case 'ksc5636':
1371:                 return 'KSC5636';
1372: 
1373:             case 'cskz1048':
1374:             case 'kz1048':
1375:             case 'rk1048':
1376:             case 'strk10482002':
1377:                 return 'KZ-1048';
1378: 
1379:             case 'csiso19latingreek':
1380:             case 'isoir19':
1381:             case 'latingreek':
1382:                 return 'latin-greek';
1383: 
1384:             case 'csiso27latingreek1':
1385:             case 'isoir27':
1386:             case 'latingreek1':
1387:                 return 'Latin-greek-1';
1388: 
1389:             case 'csiso158lap':
1390:             case 'isoir158':
1391:             case 'lap':
1392:             case 'latinlap':
1393:                 return 'latin-lap';
1394: 
1395:             case 'csmacintosh':
1396:             case 'mac':
1397:             case 'macintosh':
1398:                 return 'macintosh';
1399: 
1400:             case 'csmicrosoftpublishing':
1401:             case 'microsoftpublishing':
1402:                 return 'Microsoft-Publishing';
1403: 
1404:             case 'csmnem':
1405:             case 'mnem':
1406:                 return 'MNEM';
1407: 
1408:             case 'csmnemonic':
1409:             case 'mnemonic':
1410:                 return 'MNEMONIC';
1411: 
1412:             case 'csiso86hungarian':
1413:             case 'hu':
1414:             case 'iso646hu':
1415:             case 'isoir86':
1416:             case 'msz77953':
1417:                 return 'MSZ_7795.3';
1418: 
1419:             case 'csnatsdano':
1420:             case 'isoir91':
1421:             case 'natsdano':
1422:                 return 'NATS-DANO';
1423: 
1424:             case 'csnatsdanoadd':
1425:             case 'isoir92':
1426:             case 'natsdanoadd':
1427:                 return 'NATS-DANO-ADD';
1428: 
1429:             case 'csnatssefi':
1430:             case 'isoir81':
1431:             case 'natssefi':
1432:                 return 'NATS-SEFI';
1433: 
1434:             case 'csnatssefiadd':
1435:             case 'isoir82':
1436:             case 'natssefiadd':
1437:                 return 'NATS-SEFI-ADD';
1438: 
1439:             case 'csiso151cuba':
1440:             case 'cuba':
1441:             case 'iso646cu':
1442:             case 'isoir151':
1443:             case 'ncnc1081':
1444:                 return 'NC_NC00-10:81';
1445: 
1446:             case 'csiso69french':
1447:             case 'fr':
1448:             case 'iso646fr':
1449:             case 'isoir69':
1450:             case 'nfz62010':
1451:                 return 'NF_Z_62-010';
1452: 
1453:             case 'csiso25french':
1454:             case 'iso646fr1':
1455:             case 'isoir25':
1456:             case 'nfz620101973':
1457:                 return 'NF_Z_62-010_(1973)';
1458: 
1459:             case 'csiso60danishnorwegian':
1460:             case 'csiso60norwegian1':
1461:             case 'iso646no':
1462:             case 'isoir60':
1463:             case 'no':
1464:             case 'ns45511':
1465:                 return 'NS_4551-1';
1466: 
1467:             case 'csiso61norwegian2':
1468:             case 'iso646no2':
1469:             case 'isoir61':
1470:             case 'no2':
1471:             case 'ns45512':
1472:                 return 'NS_4551-2';
1473: 
1474:             case 'osdebcdicdf3irv':
1475:                 return 'OSD_EBCDIC_DF03_IRV';
1476: 
1477:             case 'osdebcdicdf41':
1478:                 return 'OSD_EBCDIC_DF04_1';
1479: 
1480:             case 'osdebcdicdf415':
1481:                 return 'OSD_EBCDIC_DF04_15';
1482: 
1483:             case 'cspc8danishnorwegian':
1484:             case 'pc8danishnorwegian':
1485:                 return 'PC8-Danish-Norwegian';
1486: 
1487:             case 'cspc8turkish':
1488:             case 'pc8turkish':
1489:                 return 'PC8-Turkish';
1490: 
1491:             case 'csiso16portuguese':
1492:             case 'iso646pt':
1493:             case 'isoir16':
1494:             case 'pt':
1495:                 return 'PT';
1496: 
1497:             case 'csiso84portuguese2':
1498:             case 'iso646pt2':
1499:             case 'isoir84':
1500:             case 'pt2':
1501:                 return 'PT2';
1502: 
1503:             case 'cp154':
1504:             case 'csptcp154':
1505:             case 'cyrillicasian':
1506:             case 'pt154':
1507:             case 'ptcp154':
1508:                 return 'PTCP154';
1509: 
1510:             case 'scsu':
1511:                 return 'SCSU';
1512: 
1513:             case 'csiso10swedish':
1514:             case 'fi':
1515:             case 'iso646fi':
1516:             case 'iso646se':
1517:             case 'isoir10':
1518:             case 'se':
1519:             case 'sen850200b':
1520:                 return 'SEN_850200_B';
1521: 
1522:             case 'csiso11swedishfornames':
1523:             case 'iso646se2':
1524:             case 'isoir11':
1525:             case 'se2':
1526:             case 'sen850200c':
1527:                 return 'SEN_850200_C';
1528: 
1529:             case 'csiso102t617bit':
1530:             case 'isoir102':
1531:             case 't617bit':
1532:                 return 'T.61-7bit';
1533: 
1534:             case 'csiso103t618bit':
1535:             case 'isoir103':
1536:             case 't61':
1537:             case 't618bit':
1538:                 return 'T.61-8bit';
1539: 
1540:             case 'csiso128t101g2':
1541:             case 'isoir128':
1542:             case 't101g2':
1543:                 return 'T.101-G2';
1544: 
1545:             case 'cstscii':
1546:             case 'tscii':
1547:                 return 'TSCII';
1548: 
1549:             case 'csunicode11':
1550:             case 'unicode11':
1551:                 return 'UNICODE-1-1';
1552: 
1553:             case 'csunicode11utf7':
1554:             case 'unicode11utf7':
1555:                 return 'UNICODE-1-1-UTF-7';
1556: 
1557:             case 'csunknown8bit':
1558:             case 'unknown8bit':
1559:                 return 'UNKNOWN-8BIT';
1560: 
1561:             case 'ansix341968':
1562:             case 'ansix341986':
1563:             case 'ascii':
1564:             case 'cp367':
1565:             case 'csascii':
1566:             case 'ibm367':
1567:             case 'iso646irv1991':
1568:             case 'iso646us':
1569:             case 'isoir6':
1570:             case 'us':
1571:             case 'usascii':
1572:                 return 'US-ASCII';
1573: 
1574:             case 'csusdk':
1575:             case 'usdk':
1576:                 return 'us-dk';
1577: 
1578:             case 'utf7':
1579:                 return 'UTF-7';
1580: 
1581:             case 'utf8':
1582:                 return 'UTF-8';
1583: 
1584:             case 'utf16':
1585:                 return 'UTF-16';
1586: 
1587:             case 'utf16be':
1588:                 return 'UTF-16BE';
1589: 
1590:             case 'utf16le':
1591:                 return 'UTF-16LE';
1592: 
1593:             case 'utf32':
1594:                 return 'UTF-32';
1595: 
1596:             case 'utf32be':
1597:                 return 'UTF-32BE';
1598: 
1599:             case 'utf32le':
1600:                 return 'UTF-32LE';
1601: 
1602:             case 'csventurainternational':
1603:             case 'venturainternational':
1604:                 return 'Ventura-International';
1605: 
1606:             case 'csventuramath':
1607:             case 'venturamath':
1608:                 return 'Ventura-Math';
1609: 
1610:             case 'csventuraus':
1611:             case 'venturaus':
1612:                 return 'Ventura-US';
1613: 
1614:             case 'csiso70videotexsupp1':
1615:             case 'isoir70':
1616:             case 'videotexsuppl':
1617:                 return 'videotex-suppl';
1618: 
1619:             case 'csviqr':
1620:             case 'viqr':
1621:                 return 'VIQR';
1622: 
1623:             case 'csviscii':
1624:             case 'viscii':
1625:                 return 'VISCII';
1626: 
1627:             case 'csshiftjis':
1628:             case 'cswindows31j':
1629:             case 'mskanji':
1630:             case 'shiftjis':
1631:             case 'windows31j':
1632:                 return 'Windows-31J';
1633: 
1634:             case 'iso885911':
1635:             case 'tis620':
1636:                 return 'windows-874';
1637: 
1638:             case 'cseuckr':
1639:             case 'csksc56011987':
1640:             case 'euckr':
1641:             case 'isoir149':
1642:             case 'korean':
1643:             case 'ksc5601':
1644:             case 'ksc56011987':
1645:             case 'ksc56011989':
1646:             case 'windows949':
1647:                 return 'windows-949';
1648: 
1649:             case 'windows1250':
1650:                 return 'windows-1250';
1651: 
1652:             case 'windows1251':
1653:                 return 'windows-1251';
1654: 
1655:             case 'cp819':
1656:             case 'csisolatin1':
1657:             case 'ibm819':
1658:             case 'iso88591':
1659:             case 'iso885911987':
1660:             case 'isoir100':
1661:             case 'l1':
1662:             case 'latin1':
1663:             case 'windows1252':
1664:                 return 'windows-1252';
1665: 
1666:             case 'windows1253':
1667:                 return 'windows-1253';
1668: 
1669:             case 'csisolatin5':
1670:             case 'iso88599':
1671:             case 'iso885991989':
1672:             case 'isoir148':
1673:             case 'l5':
1674:             case 'latin5':
1675:             case 'windows1254':
1676:                 return 'windows-1254';
1677: 
1678:             case 'windows1255':
1679:                 return 'windows-1255';
1680: 
1681:             case 'windows1256':
1682:                 return 'windows-1256';
1683: 
1684:             case 'windows1257':
1685:                 return 'windows-1257';
1686: 
1687:             case 'windows1258':
1688:                 return 'windows-1258';
1689: 
1690:             default:
1691:                 return $charset;
1692:         }
1693:     }
1694: 
1695:     public static function get_curl_version()
1696:     {
1697:         if (is_array($curl = curl_version()))
1698:         {
1699:             $curl = $curl['version'];
1700:         }
1701:         elseif (substr($curl, 0, 5) === 'curl/')
1702:         {
1703:             $curl = substr($curl, 5, strcspn($curl, "\x09\x0A\x0B\x0C\x0D", 5));
1704:         }
1705:         elseif (substr($curl, 0, 8) === 'libcurl/')
1706:         {
1707:             $curl = substr($curl, 8, strcspn($curl, "\x09\x0A\x0B\x0C\x0D", 8));
1708:         }
1709:         else
1710:         {
1711:             $curl = 0;
1712:         }
1713:         return $curl;
1714:     }
1715: 
1716:     /**
1717:      * Strip HTML comments
1718:      *
1719:      * @param string $data Data to strip comments from
1720:      * @return string Comment stripped string
1721:      */
1722:     public static function strip_comments($data)
1723:     {
1724:         $output = '';
1725:         while (($start = strpos($data, '<!--')) !== false)
1726:         {
1727:             $output .= substr($data, 0, $start);
1728:             if (($end = strpos($data, '-->', $start)) !== false)
1729:             {
1730:                 $data = substr_replace($data, '', 0, $end + 3);
1731:             }
1732:             else
1733:             {
1734:                 $data = '';
1735:             }
1736:         }
1737:         return $output . $data;
1738:     }
1739: 
1740:     public static function parse_date($dt)
1741:     {
1742:         $parser = SimplePie_Parse_Date::get();
1743:         return $parser->parse($dt);
1744:     }
1745: 
1746:     /**
1747:      * Decode HTML entities
1748:      *
1749:      * @deprecated Use DOMDocument instead
1750:      * @param string $data Input data
1751:      * @return string Output data
1752:      */
1753:     public static function entities_decode($data)
1754:     {
1755:         $decoder = new SimplePie_Decode_HTML_Entities($data);
1756:         return $decoder->parse();
1757:     }
1758: 
1759:     /**
1760:      * Remove RFC822 comments
1761:      *
1762:      * @param string $data Data to strip comments from
1763:      * @return string Comment stripped string
1764:      */
1765:     public static function uncomment_rfc822($string)
1766:     {
1767:         $string = (string) $string;
1768:         $position = 0;
1769:         $length = strlen($string);
1770:         $depth = 0;
1771: 
1772:         $output = '';
1773: 
1774:         while ($position < $length && ($pos = strpos($string, '(', $position)) !== false)
1775:         {
1776:             $output .= substr($string, $position, $pos - $position);
1777:             $position = $pos + 1;
1778:             if ($string[$pos - 1] !== '\\')
1779:             {
1780:                 $depth++;
1781:                 while ($depth && $position < $length)
1782:                 {
1783:                     $position += strcspn($string, '()', $position);
1784:                     if ($string[$position - 1] === '\\')
1785:                     {
1786:                         $position++;
1787:                         continue;
1788:                     }
1789:                     elseif (isset($string[$position]))
1790:                     {
1791:                         switch ($string[$position])
1792:                         {
1793:                             case '(':
1794:                                 $depth++;
1795:                                 break;
1796: 
1797:                             case ')':
1798:                                 $depth--;
1799:                                 break;
1800:                         }
1801:                         $position++;
1802:                     }
1803:                     else
1804:                     {
1805:                         break;
1806:                     }
1807:                 }
1808:             }
1809:             else
1810:             {
1811:                 $output .= '(';
1812:             }
1813:         }
1814:         $output .= substr($string, $position);
1815: 
1816:         return $output;
1817:     }
1818: 
1819:     public static function parse_mime($mime)
1820:     {
1821:         if (($pos = strpos($mime, ';')) === false)
1822:         {
1823:             return trim($mime);
1824:         }
1825:         else
1826:         {
1827:             return trim(substr($mime, 0, $pos));
1828:         }
1829:     }
1830: 
1831:     public static function atom_03_construct_type($attribs)
1832:     {
1833:         if (isset($attribs['']['mode']) && strtolower(trim($attribs['']['mode']) === 'base64'))
1834:         {
1835:             $mode = SIMPLEPIE_CONSTRUCT_BASE64;
1836:         }
1837:         else
1838:         {
1839:             $mode = SIMPLEPIE_CONSTRUCT_NONE;
1840:         }
1841:         if (isset($attribs['']['type']))
1842:         {
1843:             switch (strtolower(trim($attribs['']['type'])))
1844:             {
1845:                 case 'text':
1846:                 case 'text/plain':
1847:                     return SIMPLEPIE_CONSTRUCT_TEXT | $mode;
1848: 
1849:                 case 'html':
1850:                 case 'text/html':
1851:                     return SIMPLEPIE_CONSTRUCT_HTML | $mode;
1852: 
1853:                 case 'xhtml':
1854:                 case 'application/xhtml+xml':
1855:                     return SIMPLEPIE_CONSTRUCT_XHTML | $mode;
1856: 
1857:                 default:
1858:                     return SIMPLEPIE_CONSTRUCT_NONE | $mode;
1859:             }
1860:         }
1861:         else
1862:         {
1863:             return SIMPLEPIE_CONSTRUCT_TEXT | $mode;
1864:         }
1865:     }
1866: 
1867:     public static function atom_10_construct_type($attribs)
1868:     {
1869:         if (isset($attribs['']['type']))
1870:         {
1871:             switch (strtolower(trim($attribs['']['type'])))
1872:             {
1873:                 case 'text':
1874:                     return SIMPLEPIE_CONSTRUCT_TEXT;
1875: 
1876:                 case 'html':
1877:                     return SIMPLEPIE_CONSTRUCT_HTML;
1878: 
1879:                 case 'xhtml':
1880:                     return SIMPLEPIE_CONSTRUCT_XHTML;
1881: 
1882:                 default:
1883:                     return SIMPLEPIE_CONSTRUCT_NONE;
1884:             }
1885:         }
1886:         return SIMPLEPIE_CONSTRUCT_TEXT;
1887:     }
1888: 
1889:     public static function atom_10_content_construct_type($attribs)
1890:     {
1891:         if (isset($attribs['']['type']))
1892:         {
1893:             $type = strtolower(trim($attribs['']['type']));
1894:             switch ($type)
1895:             {
1896:                 case 'text':
1897:                     return SIMPLEPIE_CONSTRUCT_TEXT;
1898: 
1899:                 case 'html':
1900:                     return SIMPLEPIE_CONSTRUCT_HTML;
1901: 
1902:                 case 'xhtml':
1903:                     return SIMPLEPIE_CONSTRUCT_XHTML;
1904:             }
1905:             if (in_array(substr($type, -4), array('+xml', '/xml')) || substr($type, 0, 5) === 'text/')
1906:             {
1907:                 return SIMPLEPIE_CONSTRUCT_NONE;
1908:             }
1909:             else
1910:             {
1911:                 return SIMPLEPIE_CONSTRUCT_BASE64;
1912:             }
1913:         }
1914:         else
1915:         {
1916:             return SIMPLEPIE_CONSTRUCT_TEXT;
1917:         }
1918:     }
1919: 
1920:     public static function is_isegment_nz_nc($string)
1921:     {
1922:         return (bool) preg_match('/^([A-Za-z0-9\-._~\x{A0}-\x{D7FF}\x{F900}-\x{FDCF}\x{FDF0}-\x{FFEF}\x{10000}-\x{1FFFD}\x{20000}-\x{2FFFD}\x{30000}-\x{3FFFD}\x{40000}-\x{4FFFD}\x{50000}-\x{5FFFD}\x{60000}-\x{6FFFD}\x{70000}-\x{7FFFD}\x{80000}-\x{8FFFD}\x{90000}-\x{9FFFD}\x{A0000}-\x{AFFFD}\x{B0000}-\x{BFFFD}\x{C0000}-\x{CFFFD}\x{D0000}-\x{DFFFD}\x{E1000}-\x{EFFFD}!$&\'()*+,;=@]|(%[0-9ABCDEF]{2}))+$/u', $string);
1923:     }
1924: 
1925:     public static function space_seperated_tokens($string)
1926:     {
1927:         $space_characters = "\x20\x09\x0A\x0B\x0C\x0D";
1928:         $string_length = strlen($string);
1929: 
1930:         $position = strspn($string, $space_characters);
1931:         $tokens = array();
1932: 
1933:         while ($position < $string_length)
1934:         {
1935:             $len = strcspn($string, $space_characters, $position);
1936:             $tokens[] = substr($string, $position, $len);
1937:             $position += $len;
1938:             $position += strspn($string, $space_characters, $position);
1939:         }
1940: 
1941:         return $tokens;
1942:     }
1943: 
1944:     /**
1945:      * Converts a unicode codepoint to a UTF-8 character
1946:      *
1947:      * @static
1948:      * @param int $codepoint Unicode codepoint
1949:      * @return string UTF-8 character
1950:      */
1951:     public static function codepoint_to_utf8($codepoint)
1952:     {
1953:         $codepoint = (int) $codepoint;
1954:         if ($codepoint < 0)
1955:         {
1956:             return false;
1957:         }
1958:         else if ($codepoint <= 0x7f)
1959:         {
1960:             return chr($codepoint);
1961:         }
1962:         else if ($codepoint <= 0x7ff)
1963:         {
1964:             return chr(0xc0 | ($codepoint >> 6)) . chr(0x80 | ($codepoint & 0x3f));
1965:         }
1966:         else if ($codepoint <= 0xffff)
1967:         {
1968:             return chr(0xe0 | ($codepoint >> 12)) . chr(0x80 | (($codepoint >> 6) & 0x3f)) . chr(0x80 | ($codepoint & 0x3f));
1969:         }
1970:         else if ($codepoint <= 0x10ffff)
1971:         {
1972:             return chr(0xf0 | ($codepoint >> 18)) . chr(0x80 | (($codepoint >> 12) & 0x3f)) . chr(0x80 | (($codepoint >> 6) & 0x3f)) . chr(0x80 | ($codepoint & 0x3f));
1973:         }
1974:         else
1975:         {
1976:             // U+FFFD REPLACEMENT CHARACTER
1977:             return "\xEF\xBF\xBD";
1978:         }
1979:     }
1980: 
1981:     /**
1982:      * Similar to parse_str()
1983:      *
1984:      * Returns an associative array of name/value pairs, where the value is an
1985:      * array of values that have used the same name
1986:      *
1987:      * @static
1988:      * @param string $str The input string.
1989:      * @return array
1990:      */
1991:     public static function parse_str($str)
1992:     {
1993:         $return = array();
1994:         $str = explode('&', $str);
1995: 
1996:         foreach ($str as $section)
1997:         {
1998:             if (strpos($section, '=') !== false)
1999:             {
2000:                 list($name, $value) = explode('=', $section, 2);
2001:                 $return[urldecode($name)][] = urldecode($value);
2002:             }
2003:             else
2004:             {
2005:                 $return[urldecode($section)][] = null;
2006:             }
2007:         }
2008: 
2009:         return $return;
2010:     }
2011: 
2012:     /**
2013:      * Detect XML encoding, as per XML 1.0 Appendix F.1
2014:      *
2015:      * @todo Add support for EBCDIC
2016:      * @param string $data XML data
2017:      * @param SimplePie_Registry $registry Class registry
2018:      * @return array Possible encodings
2019:      */
2020:     public static function xml_encoding($data, $registry)
2021:     {
2022:         // UTF-32 Big Endian BOM
2023:         if (substr($data, 0, 4) === "\x00\x00\xFE\xFF")
2024:         {
2025:             $encoding[] = 'UTF-32BE';
2026:         }
2027:         // UTF-32 Little Endian BOM
2028:         elseif (substr($data, 0, 4) === "\xFF\xFE\x00\x00")
2029:         {
2030:             $encoding[] = 'UTF-32LE';
2031:         }
2032:         // UTF-16 Big Endian BOM
2033:         elseif (substr($data, 0, 2) === "\xFE\xFF")
2034:         {
2035:             $encoding[] = 'UTF-16BE';
2036:         }
2037:         // UTF-16 Little Endian BOM
2038:         elseif (substr($data, 0, 2) === "\xFF\xFE")
2039:         {
2040:             $encoding[] = 'UTF-16LE';
2041:         }
2042:         // UTF-8 BOM
2043:         elseif (substr($data, 0, 3) === "\xEF\xBB\xBF")
2044:         {
2045:             $encoding[] = 'UTF-8';
2046:         }
2047:         // UTF-32 Big Endian Without BOM
2048:         elseif (substr($data, 0, 20) === "\x00\x00\x00\x3C\x00\x00\x00\x3F\x00\x00\x00\x78\x00\x00\x00\x6D\x00\x00\x00\x6C")
2049:         {
2050:             if ($pos = strpos($data, "\x00\x00\x00\x3F\x00\x00\x00\x3E"))
2051:             {
2052:                 $parser = $registry->create('XML_Declaration_Parser', array(SimplePie_Misc::change_encoding(substr($data, 20, $pos - 20), 'UTF-32BE', 'UTF-8')));
2053:                 if ($parser->parse())
2054:                 {
2055:                     $encoding[] = $parser->encoding;
2056:                 }
2057:             }
2058:             $encoding[] = 'UTF-32BE';
2059:         }
2060:         // UTF-32 Little Endian Without BOM
2061:         elseif (substr($data, 0, 20) === "\x3C\x00\x00\x00\x3F\x00\x00\x00\x78\x00\x00\x00\x6D\x00\x00\x00\x6C\x00\x00\x00")
2062:         {
2063:             if ($pos = strpos($data, "\x3F\x00\x00\x00\x3E\x00\x00\x00"))
2064:             {
2065:                 $parser = $registry->create('XML_Declaration_Parser', array(SimplePie_Misc::change_encoding(substr($data, 20, $pos - 20), 'UTF-32LE', 'UTF-8')));
2066:                 if ($parser->parse())
2067:                 {
2068:                     $encoding[] = $parser->encoding;
2069:                 }
2070:             }
2071:             $encoding[] = 'UTF-32LE';
2072:         }
2073:         // UTF-16 Big Endian Without BOM
2074:         elseif (substr($data, 0, 10) === "\x00\x3C\x00\x3F\x00\x78\x00\x6D\x00\x6C")
2075:         {
2076:             if ($pos = strpos($data, "\x00\x3F\x00\x3E"))
2077:             {
2078:                 $parser = $registry->create('XML_Declaration_Parser', array(SimplePie_Misc::change_encoding(substr($data, 20, $pos - 10), 'UTF-16BE', 'UTF-8')));
2079:                 if ($parser->parse())
2080:                 {
2081:                     $encoding[] = $parser->encoding;
2082:                 }
2083:             }
2084:             $encoding[] = 'UTF-16BE';
2085:         }
2086:         // UTF-16 Little Endian Without BOM
2087:         elseif (substr($data, 0, 10) === "\x3C\x00\x3F\x00\x78\x00\x6D\x00\x6C\x00")
2088:         {
2089:             if ($pos = strpos($data, "\x3F\x00\x3E\x00"))
2090:             {
2091:                 $parser = $registry->create('XML_Declaration_Parser', array(SimplePie_Misc::change_encoding(substr($data, 20, $pos - 10), 'UTF-16LE', 'UTF-8')));
2092:                 if ($parser->parse())
2093:                 {
2094:                     $encoding[] = $parser->encoding;
2095:                 }
2096:             }
2097:             $encoding[] = 'UTF-16LE';
2098:         }
2099:         // US-ASCII (or superset)
2100:         elseif (substr($data, 0, 5) === "\x3C\x3F\x78\x6D\x6C")
2101:         {
2102:             if ($pos = strpos($data, "\x3F\x3E"))
2103:             {
2104:                 $parser = $registry->create('XML_Declaration_Parser', array(substr($data, 5, $pos - 5)));
2105:                 if ($parser->parse())
2106:                 {
2107:                     $encoding[] = $parser->encoding;
2108:                 }
2109:             }
2110:             $encoding[] = 'UTF-8';
2111:         }
2112:         // Fallback to UTF-8
2113:         else
2114:         {
2115:             $encoding[] = 'UTF-8';
2116:         }
2117:         return $encoding;
2118:     }
2119: 
2120:     public static function output_javascript()
2121:     {
2122:         if (function_exists('ob_gzhandler'))
2123:         {
2124:             ob_start('ob_gzhandler');
2125:         }
2126:         header('Content-type: text/javascript; charset: UTF-8');
2127:         header('Cache-Control: must-revalidate');
2128:         header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 604800) . ' GMT'); // 7 days
2129:         ?>
2130: function embed_quicktime(type, bgcolor, width, height, link, placeholder, loop) {
2131:     if (placeholder != '') {
2132:         document.writeln('<embed type="'+type+'" style="cursor:hand; cursor:pointer;" href="'+link+'" src="'+placeholder+'" width="'+width+'" height="'+height+'" autoplay="false" target="myself" controller="false" loop="'+loop+'" scale="aspect" bgcolor="'+bgcolor+'" pluginspage="http://www.apple.com/quicktime/download/"></embed>');
2133:     }
2134:     else {
2135:         document.writeln('<embed type="'+type+'" style="cursor:hand; cursor:pointer;" src="'+link+'" width="'+width+'" height="'+height+'" autoplay="false" target="myself" controller="true" loop="'+loop+'" scale="aspect" bgcolor="'+bgcolor+'" pluginspage="http://www.apple.com/quicktime/download/"></embed>');
2136:     }
2137: }
2138: 
2139: function embed_flash(bgcolor, width, height, link, loop, type) {
2140:     document.writeln('<embed src="'+link+'" pluginspage="http://www.macromedia.com/go/getflashplayer" type="'+type+'" quality="high" width="'+width+'" height="'+height+'" bgcolor="'+bgcolor+'" loop="'+loop+'"></embed>');
2141: }
2142: 
2143: function embed_flv(width, height, link, placeholder, loop, player) {
2144:     document.writeln('<embed src="'+player+'" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" quality="high" width="'+width+'" height="'+height+'" wmode="transparent" flashvars="file='+link+'&autostart=false&repeat='+loop+'&showdigits=true&showfsbutton=false"></embed>');
2145: }
2146: 
2147: function embed_wmedia(width, height, link) {
2148:     document.writeln('<embed type="application/x-mplayer2" src="'+link+'" autosize="1" width="'+width+'" height="'+height+'" showcontrols="1" showstatusbar="0" showdisplay="0" autostart="0"></embed>');
2149: }
2150:         <?php
2151:     }
2152: 
2153:     /**
2154:      * Get the SimplePie build timestamp
2155:      *
2156:      * Uses the git index if it exists, otherwise uses the modification time
2157:      * of the newest file.
2158:      */
2159:     public static function get_build()
2160:     {
2161:         $root = dirname(dirname(__FILE__));
2162:         if (file_exists($root . '/.git/index'))
2163:         {
2164:             return filemtime($root . '/.git/index');
2165:         }
2166:         elseif (file_exists($root . '/SimplePie'))
2167:         {
2168:             $time = 0;
2169:             foreach (glob($root . '/SimplePie/*.php') as $file)
2170:             {
2171:                 if (($mtime = filemtime($file)) > $time)
2172:                 {
2173:                     $time = $mtime;
2174:                 }
2175:             }
2176:             return $time;
2177:         }
2178:         elseif (file_exists(dirname(__FILE__) . '/Core.php'))
2179:         {
2180:             return filemtime(dirname(__FILE__) . '/Core.php');
2181:         }
2182:         else
2183:         {
2184:             return filemtime(__FILE__);
2185:         }
2186:     }
2187: 
2188:     /**
2189:      * Format debugging information
2190:      */
2191:     public static function debug(&$sp)
2192:     {
2193:         $info = 'SimplePie ' . SIMPLEPIE_VERSION . ' Build ' . SIMPLEPIE_BUILD . "\n";
2194:         $info .= 'PHP ' . PHP_VERSION . "\n";
2195:         if ($sp->error() !== null)
2196:         {
2197:             $info .= 'Error occurred: ' . $sp->error() . "\n";
2198:         }
2199:         else
2200:         {
2201:             $info .= "No error found.\n";
2202:         }
2203:         $info .= "Extensions:\n";
2204:         $extensions = array('pcre', 'curl', 'zlib', 'mbstring', 'iconv', 'xmlreader', 'xml');
2205:         foreach ($extensions as $ext)
2206:         {
2207:             if (extension_loaded($ext))
2208:             {
2209:                 $info .= "    $ext loaded\n";
2210:                 switch ($ext)
2211:                 {
2212:                     case 'pcre':
2213:                         $info .= '      Version ' . PCRE_VERSION . "\n";
2214:                         break;
2215:                     case 'curl':
2216:                         $version = curl_version();
2217:                         $info .= '      Version ' . $version['version'] . "\n";
2218:                         break;
2219:                     case 'mbstring':
2220:                         $info .= '      Overloading: ' . mb_get_info('func_overload') . "\n";
2221:                         break;
2222:                     case 'iconv':
2223:                         $info .= '      Version ' . ICONV_VERSION . "\n";
2224:                         break;
2225:                     case 'xml':
2226:                         $info .= '      Version ' . LIBXML_DOTTED_VERSION . "\n";
2227:                         break;
2228:                 }
2229:             }
2230:             else
2231:             {
2232:                 $info .= "    $ext not loaded\n";
2233:             }
2234:         }
2235:         return $info;
2236:     }
2237: 
2238:     public static function silence_errors($num, $str)
2239:     {
2240:         // No-op
2241:     }
2242: }
2243: 
2244: 

Show some love! Wishlists for Geoffrey, Ryan P., and Ryan M.

SimplePie is © 2004–2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue and contributors. Licensed under the BSD License. Hosted thanks to Matt Mullenweg, API documentation generated by ApiGen 2.6.1. Variation on the Feed Icon by Wolfgang Bartelme.