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