case 'csiso16portuguese':
case 'csiso84portuguese2':
case 'csiso11swedishfornames':
return 'UNICODE-1-1-UTF-7';
case 'csventurainternational':
case 'venturainternational':
return 'Ventura-International';
case 'csiso70videotexsupp1':
public static function get_curl_version()
if (is_array($curl = curl_version())) {
$curl = $curl['version'];
* @deprecated since SimplePie 1.9.0. If you need it, you can copy the function to your codebase. But you should consider using `DOMDocument` for any DOM wrangling.
* @param string $data Data to strip comments from
* @return string Comment stripped string
public static function strip_comments(string $data)
// trigger_error(sprintf('Using method "' . __METHOD__ . '" is deprecated since SimplePie 1.9.'), \E_USER_DEPRECATED);
while (($start = strpos($data, '<!--')) !== false) {
$output .= substr($data, 0, $start);
if (($end = strpos($data, '-->', $start)) !== false) {
$data = substr_replace($data, '', 0, $end + 3);
public static function parse_date(string $dt)
$parser = \SimplePie\Parse\Date::get();
return $parser->parse($dt);
* @deprecated since SimplePie 1.3, use DOMDocument instead
* @param string $data Input data
* @return string Output data
public static function entities_decode(string $data)
// trigger_error(sprintf('Using method "' . __METHOD__ . '" is deprecated since SimplePie 1.3, use "DOMDocument" instead.'), \E_USER_DEPRECATED);
$decoder = new \SimplePie_Decode_HTML_Entities($data);
return $decoder->parse();
* @deprecated since SimplePie 1.9.0. If you need it, consider copying the function to your codebase.
* @param string $string Data to strip comments from
* @return string Comment stripped string
public static function uncomment_rfc822(string $string)
// trigger_error(sprintf('Using method "' . __METHOD__ . '" is deprecated since SimplePie 1.9.'), \E_USER_DEPRECATED);
$length = strlen($string);
while ($position < $length && ($pos = strpos($string, '(', $position)) !== false) {
$output .= substr($string, $position, $pos - $position);
if ($string[$pos - 1] !== '\\') {
while ($depth && $position < $length) {
$position += strcspn($string, '()', $position);
if ($string[$position - 1] === '\\') {
} elseif (isset($string[$position])) {
switch ($string[$position]) {
$output .= substr($string, $position);
public static function parse_mime(string $mime)
if (($pos = strpos($mime, ';')) === false) {
return trim(substr($mime, 0, $pos));
* @param array<string, array<string, string>> $attribs
* @return int-mask-of<SimplePie::CONSTRUCT_*>
public static function atom_03_construct_type(array $attribs)
if (isset($attribs['']['mode']) && strtolower(trim($attribs['']['mode'])) === 'base64') {
$mode = \SimplePie\SimplePie::CONSTRUCT_BASE64;
$mode = \SimplePie\SimplePie::CONSTRUCT_NONE;
if (isset($attribs['']['type'])) {
switch (strtolower(trim($attribs['']['type']))) {
return \SimplePie\SimplePie::CONSTRUCT_TEXT | $mode;
return \SimplePie\SimplePie::CONSTRUCT_HTML | $mode;
case 'application/xhtml+xml':
return \SimplePie\SimplePie::CONSTRUCT_XHTML | $mode;
return \SimplePie\SimplePie::CONSTRUCT_NONE | $mode;
return \SimplePie\SimplePie::CONSTRUCT_TEXT | $mode;
* @param array<string, array<string, string>> $attribs
* @return int-mask-of<SimplePie::CONSTRUCT_*>
public static function atom_10_construct_type(array $attribs)
if (isset($attribs['']['type'])) {
switch (strtolower(trim($attribs['']['type']))) {
return \SimplePie\SimplePie::CONSTRUCT_TEXT;
return \SimplePie\SimplePie::CONSTRUCT_HTML;
return \SimplePie\SimplePie::CONSTRUCT_XHTML;
return \SimplePie\SimplePie::CONSTRUCT_NONE;
return \SimplePie\SimplePie::CONSTRUCT_TEXT;
* @param array<string, array<string, string>> $attribs
* @return int-mask-of<SimplePie::CONSTRUCT_*>
public static function atom_10_content_construct_type(array $attribs)
if (isset($attribs['']['type'])) {
$type = strtolower(trim($attribs['']['type']));
return \SimplePie\SimplePie::CONSTRUCT_TEXT;
return \SimplePie\SimplePie::CONSTRUCT_HTML;
return \SimplePie\SimplePie::CONSTRUCT_XHTML;
if (in_array(substr($type, -4), ['+xml', '/xml']) || substr($type, 0, 5) === 'text/') {
return \SimplePie\SimplePie::CONSTRUCT_NONE;
return \SimplePie\SimplePie::CONSTRUCT_BASE64;
return \SimplePie\SimplePie::CONSTRUCT_TEXT;
public static function is_isegment_nz_nc(string $string)
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);
public static function space_separated_tokens(string $string)
$space_characters = "\x20\x09\x0A\x0B\x0C\x0D";
$string_length = strlen($string);
$position = strspn($string, $space_characters);
while ($position < $string_length) {
$len = strcspn($string, $space_characters, $position);
$tokens[] = substr($string, $position, $len);
$position += strspn($string, $space_characters, $position);
* Converts a unicode codepoint to a UTF-8 character
* @param int $codepoint Unicode codepoint
* @return string|false UTF-8 character
public static function codepoint_to_utf8(int $codepoint)
} elseif ($codepoint <= 0x7f) {
} elseif ($codepoint <= 0x7ff) {
return chr(0xc0 | ($codepoint >> 6)) . chr(0x80 | ($codepoint & 0x3f));
} elseif ($codepoint <= 0xffff) {
return chr(0xe0 | ($codepoint >> 12)) . chr(0x80 | (($codepoint >> 6) & 0x3f)) . chr(0x80 | ($codepoint & 0x3f));
} elseif ($codepoint <= 0x10ffff) {
return chr(0xf0 | ($codepoint >> 18)) . chr(0x80 | (($codepoint >> 12) & 0x3f)) . chr(0x80 | (($codepoint >> 6) & 0x3f)) . chr(0x80 | ($codepoint & 0x3f));
// U+FFFD REPLACEMENT CHARACTER
* Returns an associative array of name/value pairs, where the value is an
* array of values that have used the same name
* @deprecated since SimplePie 1.9.0. If you need it, consider copying the function to your codebase.
* @param string $str The input string.
* @return array<string, array<string|null>>
public static function parse_str(string $str)
// trigger_error(sprintf('Using method "' . __METHOD__ . '" is deprecated since SimplePie 1.9.'), \E_USER_DEPRECATED);
$str = explode('&', $str);
foreach ($str as $section) {
if (strpos($section, '=') !== false) {
[$name, $value] = explode('=', $section, 2);
$return[urldecode($name)][] = urldecode($value);
$return[urldecode($section)][] = null;
* Detect XML encoding, as per XML 1.0 Appendix F.1
* @todo Add support for EBCDIC