Overview

Packages

  • None
  • SimplePie

Classes

  • SimplePie
  • SimplePie_Author
  • SimplePie_Autoloader
  • SimplePie_Cache
  • SimplePie_Cache_DB
  • SimplePie_Cache_File
  • SimplePie_Cache_Memcache
  • SimplePie_Cache_MySQL
  • SimplePie_Caption
  • SimplePie_Category
  • SimplePie_Content_Type_Sniffer
  • SimplePie_Copyright
  • SimplePie_Core
  • SimplePie_Credit
  • SimplePie_Decode_HTML_Entities
  • SimplePie_Enclosure
  • SimplePie_File
  • SimplePie_gzdecode
  • SimplePie_HTTP_Parser
  • SimplePie_IRI
  • SimplePie_Item
  • SimplePie_Locator
  • SimplePie_Misc
  • SimplePie_Net_IPv6
  • SimplePie_Parse_Date
  • SimplePie_Parser
  • SimplePie_Rating
  • SimplePie_Registry
  • SimplePie_Restriction
  • SimplePie_Sanitize
  • SimplePie_Source
  • SimplePie_XML_Declaration_Parser

Interfaces

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