On 9/5/06, <b class="gmail_sendername">Guido van Rossum</b> &lt;<a href="mailto:guido@python.org">guido@python.org</a>&gt; wrote:<div><span class="gmail_quote"></span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On 9/5/06, David Hopwood &lt;<a href="mailto:david.nospam.hopwood@blueyonder.co.uk">david.nospam.hopwood@blueyonder.co.uk</a>&gt; wrote:<br>&gt; Guido van Rossum wrote:<br>&gt; &gt; On 9/5/06, Paul Prescod &lt;<a href="mailto:paul@prescod.net">
paul@prescod.net</a>&gt; wrote:<br>&gt; &gt;<br>&gt; &gt;&gt; Beyond all of that: It just seems wrong to me that I could send someone a<br>&gt; &gt;&gt; bunch of files and a Python program and their results processing them
<br>&gt; &gt;&gt; would be different from mine, despite the fact that we run the same version of<br>&gt; &gt;&gt; Python on the same operating system.<br>&gt; &gt;<br>&gt; &gt; And it seems just as wrong if Python doesn't do what the user expects.
<br>&gt; &gt; If I were a beginning Python user, I'd hate it if I had prepared a<br>&gt; &gt; simple data file in vi or notepad and my Python program wouldn't read<br>&gt; &gt; it right because Python's idea of encoding differs from my editor's.
<br>&gt;<br>&gt; I don't know about vi, but notepad will open and save files that are not in<br>&gt; the system (&quot;ANSI&quot;) encoding just fine. On opening it checks for a BOM and<br>&gt; auto-detects UTF-8 and UTF-16; on saving it will write a BOM if you choose
<br>&gt; &quot;Unicode&quot; (UTF-16LE), &quot;Unicode big-endian&quot; (UTF-16BE), or UTF-8 in the<br>&gt; Encoding drop-down box.<br>&gt;<br>&gt; This is exactly the behaviour that most users would expect of a well-behaved
<br>&gt; Unicode-aware app. It should be as easy as possible to match this behaviour<br>&gt; in a Python program.<br><br>And this is exactly why I want the determination of the default<br>encoding (i.e. the encoding to be used when opening a file when no
<br>explicit encoding is specified by the Python code that does the<br>opening) to be open-ended, rather than picking some standard default<br>like UTF-8 and saying (like Paul seems to want to say) &quot;this is it&quot;.
</blockquote><div><br>
I never suggested that UTF-8 should be the default. In fact, I think it
was very wise of Python 2.x to make ASCII the default and I'm astounded
to hear that you regret that decision. &quot;<a name="zen">In the face of ambiguity, refuse the temptation to guess.&quot;<br>
<br>
Python 2.x provided an option to allow users to change the default
system-wide and ever since then we've (almost unanimously) counselled
users against changing it.<br>
</a></div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">&gt; &gt; Sorry Paul, I appreciate your standards-driven perspective, but in<br>
&gt; &gt; this area I'd rather build in more flexibility than strictly needed,<br>&gt; &gt; than too little. If it turns out that on a particular platform all<br>&gt; &gt; files are in UTF-8, making Python *on that platform* always choose
<br>&gt; &gt; UTF-8 is simple enough.<br>&gt;<br>&gt; The problem is not the systems where all files are UTF-8, or all files are<br>&gt; another known charset. The problem is the platforms where half of the files<br>&gt; are UTF-8 and half are in some other charset, determined either by type or by
<br>&gt; presence of a UTF-8 BOM. This is a *very* common situation, especially for<br>&gt; European users.<br><br>Right. (And Paul appears to be ignorant of this.)</blockquote><div><br>
I don't see how the fact that an individual system can have half of the
files in one encoding and half in another could argue IN FAVOUR of a
system-global default. I would have thought it strengthens my argument AGAINST trying to apply a random encoding to files.<br>
<br>
You said:<br>
<br>
&quot;If on a particular box<br>
most files are encoded in encoding X, and the user did whatever is<br>
necessary to tell the tools that that's their preferred encoding, I<br>
want Python to honor that encoding when opening text files, unless the<br>
program makes other arrangements explicitly (such as specifying an<br>
explicit encoding as a parameter to open()).&quot;<br>
<br>
But there is no such thing that &quot;most users do&quot; to tell tool what's
their preferred encoding. Most users use some random (to them)
operating system default which on Windows is usually wrong and is
different (for no particular reason) on the Macintosh than on Linux.
Long-time Windows users in this thread cannot even agree what is the
default for US English Windows because there is no single default.
There are two.<br>
<br>
Can we at least agree that if LC_CHARSET is demonstrably wrong most of
the time on Windows that we should not use it (at least on Windows)?<br>
</div></div><br>
&nbsp;Paul Prescod<br>
<br>