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


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to