[Python-3000] Pre-PEP: Easy Text File Decoding
"Martin v. Löwis"
martin at v.loewis.de
Sat Oct 14 18:41:25 CEST 2006
David Hopwood schrieb:
>> The PEP doesn't deal with streams. It is about files.
>
> An important part of the Unix design philosophy (partially adopted by Windows)
> is to make streams and files behave as similarly as possible. It is quite
> feasible to make *some* detection algorithms work for streams, and this is
> an advantage over algorithms that don't work for streams.
There is nothing wrong with that principle. But it's just a principle.
Depending on the kind of stream, different technologies for detecting
the encoding are necessary. For example, on a Win32 terminal, a special
API is available to determine the encoding. On a Unix interactive
terminal, the locale's encoding should be assumed (and more so than for
regular files: for a file, the user may chose a different encoding;
for the console, the encoding is close to (sic) a hardware setting that
cannot be changed).
The Unix principle is often extended to reach into areas where it really
becomes inadequate, look at Plan 9 for an example. Wrt. byte streams
and encodings, the principle works only if all applications use the
same encoding (which they do on Plan 9).
Regards,
Martin
More information about the Python-3000
mailing list