[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Mixing characters and bytes



Shiro Kawai <shiro@xxxxxxxx> writes:

> One practical example is reading MIME-encoded message.
> You may switch encodings, for example:
> ASCII -> euc-jp -> ASCII -> binary -> ASCII -> utf-8.
> What I'm doing currently (in Gauche) is to layer ports; that is,
> I create a port that reads from the original port, but stops reading
> and returns EOF when it encounters a MIME boundary.  From that
> port I read the MIME header as ASCII, then layer the
> encoding-conversion port if I need one.  This is conceptually
> simple, but the drawback is that I need to buffer the data
> multiple times.

> I suppose, in srfi-68, I can do similar thing by layering streams.

You could do the exact same thing with streams, by simply using
TRANSCODE-STREAM.  You get an extra layer of buffering through the
transcoding, but that's essentially a performance advantage, I'd say.

> I don't think each stream should switch encoding in it.

Probably not, but, in theory, you could also build the functionality
into the transcoder itself.  Whether this is prettier depends heavily
on the application.

-- 
Cheers =8-} Mike
Friede, Völkerverständigung und überhaupt blabla