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\MimeCode
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);
}
}