[Python-Dev] XML codec?

"Martin v. Löwis" martin at v.loewis.de
Sat Nov 10 09:52:59 CET 2007


>  > In case it isn't clear - this is exactly my view also.
> 
> But is there an API to do it?  As MAL points out that API would have
> to return not an encoding, but a pair of an encoding and the rewound
> stream.  

The API wouldn't operate on streams. Instead, you pass a string, and
it either returns the detected encoding, or an information telling that
it needs more data. No streams.

> For non-seekable, non-peekable streams (if any), what you'd
> need would be a stream that consisted of a concatenation of the
> buffered data used for detection and the continuation of the stream.

The application would read data out of the stream, and pass it to
the detection. It then can process it in whatever manner it meant to
process it in the first place.

Regards,
Martin


More information about the Python-Dev mailing list