Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Iconv.php

function Iconv::iconv_mime_decode_headers

File

vendor/symfony/polyfill-iconv/Iconv.php, line 230

Class

Iconv
iconv implementation in pure PHP, UTF-8 centric.

Namespace

Symfony\Polyfill\Iconv

Code

public static function iconv_mime_decode_headers($str, $mode = 0, $charset = null) {
    if (null === $charset) {
        $charset = self::$internalEncoding;
    }
    if (false !== strpos($str, "\r")) {
        $str = strtr(str_replace("\r\n", "\n", $str), "\r", "\n");
    }
    $str = explode("\n\n", $str, 2);
    $headers = [];
    $str = preg_split('/\\n(?![ \\t])/', $str[0]);
    foreach ($str as $str) {
        $str = self::iconv_mime_decode($str, $mode, $charset);
        if (false === $str) {
            return false;
        }
        $str = explode(':', $str, 2);
        if (2 === \count($str)) {
            if (isset($headers[$str[0]])) {
                if (!\is_array($headers[$str[0]])) {
                    $headers[$str[0]] = [
                        $headers[$str[0]],
                    ];
                }
                $headers[$str[0]][] = ltrim($str[1]);
            }
            else {
                $headers[$str[0]] = ltrim($str[1]);
            }
        }
    }
    return $headers;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal