CharsetStreamFilter extends php_user_filter
Implements a filter converting the stream's character encoding while reading from it, so the charset of strings returned by read operations are guaranteed to be encoded to UTF-8.
The underlying charset is set on the filtername used when creating the stream with stream_filter_append - it is assumed the charset is after a '.' character in the name.
Tags
Table of Contents
- STREAM_FILTER_NAME = 'mailmimeparser-encode'
- Name used when registering with stream_filter_register.
- $converter : CharsetConverter
- filter() : int
- Filter implementation converts encoding before returning PSFS_PASS_ON.
- onCreate() : mixed
- Overridden to extract the charset from the params array and check if the passed charset is supported or listed in the translation table in CharsetStreamFilter::translatedCharsets.
Constants
STREAM_FILTER_NAME
Name used when registering with stream_filter_register.
public
mixed
STREAM_FILTER_NAME
= 'mailmimeparser-encode'
Properties
$converter
protected
CharsetConverter
$converter
= null
Methods
filter()
Filter implementation converts encoding before returning PSFS_PASS_ON.
public
filter(resource $in, resource $out, int &$consumed, bool $closing) : int
Parameters
- $in : resource
- $out : resource
- $consumed : int
- $closing : bool
Return values
int —onCreate()
Overridden to extract the charset from the params array and check if the passed charset is supported or listed in the translation table in CharsetStreamFilter::translatedCharsets.
public
onCreate() : mixed
Unfortunately __construct doesn't seem to be called for this class, so setting up 'availableCharsets' in the constructor doesn't work out.