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

Breadcrumb

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

function CharacterStream::__construct

Parameters

resource|string $input:

File

vendor/symfony/mime/CharacterStream.php, line 68

Class

CharacterStream
@author Fabien Potencier <fabien@symfony.com> @author Xavier De Cock <xdecock@gmail.com>

Namespace

Symfony\Component\Mime

Code

public function __construct($input, ?string $charset = 'utf-8') {
    $charset = strtolower(trim($charset)) ?: 'utf-8';
    if ('utf-8' === $charset || 'utf8' === $charset) {
        $this->fixedWidth = 0;
        $this->map = [
            'p' => [],
            'i' => [],
        ];
    }
    else {
        $this->fixedWidth = match ($charset) {    'ucs2', 'ucs-2', 'utf16', 'utf-16' => 2,
            'ucs4', 'ucs-4', 'utf32', 'utf-32' => 4,
            default => 1,
        
        };
    }
    if (\is_resource($input)) {
        $blocks = 16372;
        while (false !== ($read = fread($input, $blocks))) {
            $this->write($read);
        }
    }
    else {
        $this->write($input);
    }
}

API Navigation

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