Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

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