G
Gandalf
Hi All!
I have a program that looks like this:
# -*- coding: iso-8859-2 -*-
s1 = 'néz'
s2 = raw_input('Please type in "néz":')
print repr(s1)
print repr(s2)
I always type in the same ('néz') on the input.
On windows, this the result:
C:\Temp\>test.py
Please type in "nÚz":néz
'n\xe9z'
'n\x82z'
C:\Temp>
On FreeBSD, this is the result:
%python ./test.py
Please type in "néz":néz
'n\xe9z'
'n\xe9z'
%
Apparently, the encoding of the python file and the encoding used on the
win32 console is different.
I need to write a console mode program that processes input from the
console. Both on UNIX and Windows.
It is no use if I give the encoding of the file, the raw input will be
still bad. Is there a way to give
an encoding for raw_input somehow? Of course I could convert the input
explicitely but it depends on the
platform.... Somehow Python should know the encoding of the console.
Comments are more than welcome.
Laci 2.0
I have a program that looks like this:
# -*- coding: iso-8859-2 -*-
s1 = 'néz'
s2 = raw_input('Please type in "néz":')
print repr(s1)
print repr(s2)
I always type in the same ('néz') on the input.
On windows, this the result:
C:\Temp\>test.py
Please type in "nÚz":néz
'n\xe9z'
'n\x82z'
C:\Temp>
On FreeBSD, this is the result:
%python ./test.py
Please type in "néz":néz
'n\xe9z'
'n\xe9z'
%
Apparently, the encoding of the python file and the encoding used on the
win32 console is different.
I need to write a console mode program that processes input from the
console. Both on UNIX and Windows.
It is no use if I give the encoding of the file, the raw input will be
still bad. Is there a way to give
an encoding for raw_input somehow? Of course I could convert the input
explicitely but it depends on the
platform.... Somehow Python should know the encoding of the console.
Comments are more than welcome.
Laci 2.0