Stream filters, converters and i18n.
| From: | Moriyoshi Koizumi | Date: | Thu, 09 Jan 2003 20:11:31 +0000 |
| Subject: | Stream filters, converters and i18n. | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-93290@lists.php.net to get a copy of this message | ||
Hi,
I renewed the base64 filter yesterday to use newly implemented
converter facility. This enables you to apply arbitrary filter
operations to a writer and a reader respectively.
But this also makes some complexity for users. How can we select
these operations? Currently there seems to be just two options:
either by filter name or by parameter.
As for the first option, according to Wez's explanation in his code,
> /* We allow very simple pattern matching for filter factories:
> * if "charset.utf-8/sjis" is requested, we search first for an exact
> * match. If that fails, we try "charset.*".
> * This means that we don't need to clog up the hashtable with a zillion
> * charsets (for example) but still be able to provide them all as filters */
I can make one generic filter factory and name it as "converter.*".
In this case, you could choose operations by the filter name like
"converter.base64-encode/base64-decode" and you could pass parameters
to each converter(filter) via the third optional parameter of
stream_filter_append() or stream_filter_prepend(). For example,
stream_filter_append($fp, "convert.quoted-printable-encode/base64-decode",
"base64-decode.ignore-eof=1,quoted-printable-encode.soft-line-break=1");
where the first part in the filter name specifies the output filter and
the second part specifies the input filter.
Otherwise I might set up a factory named "convert" which takes at least
two parameters delimited by "/". You could specify the operation like
stream_filter_append($fp, "convert",
"base64-encode:flush-on-close,forbid-seek/base64-decode:forbid-seek");
Now what do you think of this? I need a decision.
By the way, I find the converter is quite portable and also important
for i18n stuff, I'd like to make the converter independent to
the filter code. Any comments on this?
Moriyoshi