Using more than 7 bit ASCII on windows.

Paul Moore paul.moore at uk.origin-it.com
Mon Oct 30 06:03:34 EST 2000


On Sun, 29 Oct 2000 23:15:47 +0100, Mark Hammond
<MarkH at ActiveState.com> wrote:

>Paul Moore wrote:
>
>> Yes, the whole setup for non-ASCII characters seems to be very odd, if
>> not broken.
>
>It is :-(  I will fix it.  If the code works in Python.exe (as yours 
>appears to) it should work in Pythonwin.exe.

My example was in console Python, not Pythonwin.

>> Looks like the net result is that Latin-1 and the like are now
>> as hard as the multi-byte character sets, rather than making the
>> multi-byte stuff as easy as Latin-1.
>
>Don't forget that Latin-1 is not Unicode.  Python has chosen not to have 
>a default character set.
>
>So you are correct, that the "accidental" behaviour of Python strings 
>with characters > 127 were often "useful" as they used the current code 
>page.  with Unicode, such accidents can't happen - you must be explicit.

I can accept this. But I still don't know how to enter a literal
string containing a "£" character into Python. More explicitly, Python
accepts the line

    >>> s = "£"

But what does this *mean* (ie, what should I expect the semantics of s
to be?)

>> Someone please tell me I'm wrong, and explain how I should have done
>> this. You'll need to convince me that the fact that
>> 
>>     >>> os.chdir('10£')
>> 
>> doesn't work is not a bug, first...
>
>I doubt you are able to be convinced, but it is a feature.  The string 
>you reference has no meaning without knowledge of the character set. 
>Asian speakers would be happy to tell you why an assumption of "Latin-1" 
>for the default character set is not always appropriate.

No, I can be convinced. However, what I don't see is how I should
write a literal string which os.chdir will recognise as being composed
of the characters '1', '0' and '£' (ie, in whatever form necessary to
cause Python to change directory to the directory I created at NT's
command line with "mkdir 10£" in my Latin-1 setup.)

I'm not being dogmatic about this - I genuinely do find it hard to
understand what is going on.

BTW, if Python has chosen not to assign a meaning to characters above
127 (my interpretation of your comment "Python has chosen not to have
a default character set"), does that not imply that string literals
containing characters >127 should raise an exception? Otherwise, their
semantics need to be defined, and that seems to me to imply a
preferred character set...

>That said, I still agree Pythonwin should behave the same as Python.exe 
>- but _neither_ of them will allow your chdir() to work (but both 
>_should_ correctly display the string)

Fair. So the question remains, how do I chdir to a directory named
"10£"?

(My issue is different from the display issue which started the thread
- sorry, it looks like my misunderstanding has muddied the waters by
linking 2 unrelated issues...)

Paul




More information about the Python-list mailing list