locale.CODESET / different in python shell and scripts
Nuff Said
nuffsaid at phreaker.net
Fri Apr 30 05:56:19 EDT 2004
On Fri, 30 Apr 2004 04:30:34 +0200, Martin v. Löwis wrote:
> Nuff Said wrote:
>> When I add the following line to the above script
>>
>> print u"schönes Mädchen".encode(encoding)
>>
>> the result is:
>>
>> schönes Mädchen (with my self-compiled Python 2.3)
>> schönes Mädchen (with Fedora's Python 2.2)
>>
>> I observed, that my Python gives me (the correct value) 15 for
>> len(u"schönes Mädchen") whereas Fedora's Python says 17 (one more
>> for each German umlaut, i.e. the len of the UTF-8 representation of
>> the string; observe, that the file uses the coding cookie for UTF-8).
>> Maybe Fedora's Python was compiled without Unicode support?
>
> Certainly not: It would not support u"" literals without Unicode.
That's what I thought.
> Please understand that you can use non-ASCII characters in source
> code unless you also use the facilities described in
>
> http://www.python.org/peps/pep-0263.html
>
> So instead of "ö", you should write "\xf6".
But *I do use* the line
# -*- coding: UTF-8 -*-
from your PEP (directly after the shebang-line; s. the full source
code in my earlier posting). I thought, that allows me to write u"ö"
(which - as described above - works in one of my two Pythons).
??? Nuff.
More information about the Python-list
mailing list