Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401] [Versions 400 and 401] [Versions 401 and 402] [Versions 401 and 403]

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