print u"\u0432": why is this so hard? UnciodeEncodeError
David Eppstein
eppstein at ics.uci.edu
Wed Apr 14 01:26:52 EDT 2004
In article <8gbrlvz1k1.fsf at galapagos.bx.psu.edu>,
Scott Schwartz <"schwartz+ at usenet "@bio.cse.psu.edu> wrote:
> > It is: however, your locale only tells Python the encoding of your
> > terminal, not the encoding of an arbitrary file you may write to.
>
> That's not the usual interpretation of locale. It's not about
> terminals, it's about everything, especially files.
Files should be in a format that specifies the encoding explicitly,
either within the file or as part of an external file format
specification. One should not have to hope that the locale of the
person using the file is the same as that of the person who created it.
(I realize locale also affects e.g. collation order, but the most
problems come from encoding mismatches.)
--
David Eppstein http://www.ics.uci.edu/~eppstein/
Univ. of California, Irvine, School of Information & Computer Science
More information about the Python-list
mailing list