1 | <?php |
||
22 | class CharsetStreamFilter extends php_user_filter |
||
23 | { |
||
24 | /** |
||
25 | * Name used when registering with stream_filter_register. |
||
26 | */ |
||
27 | const STREAM_FILTER_NAME = 'mailmimeparser-encode.*'; |
||
28 | |||
29 | /** |
||
30 | * @var string the character set the stream is using |
||
31 | */ |
||
32 | protected $charset = 'iso-8859-1'; |
||
33 | |||
34 | /** |
||
35 | * Filter implementation converts encoding before returning PSFS_PASS_ON. |
||
36 | * |
||
37 | * @param resource $in |
||
38 | * @param resource $out |
||
39 | * @param int $consumed |
||
40 | * @param bool $closing |
||
41 | * @return int |
||
42 | */ |
||
43 | public function filter($in, $out, &$consumed, $closing) |
||
52 | |||
53 | /** |
||
54 | * Overridden to extract the charset from the filtername. An example of a |
||
55 | * filter name sent to stream_filter_append with a charset would be: |
||
56 | * |
||
57 | * stream_filter_append(resource, 'mailmimeparser-encode.utf-8'); |
||
58 | */ |
||
59 | public function onCreate() |
||
66 | } |
||
67 |