1
Vote

print u'\xe4'.encode(sys.stdout.encoding) -> ?

description

D:>ipy
IronPython 2.6.1 (2.6.10920.0) on .NET 4.0.30319.1
Type "help", "copyright", "credits" or "license" for more information.
import sys
print u'\xe4'.encode(sys.stdout.encoding)
?
 
Python 2.6.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.1500 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
import sys
print u'\xe4'.encode(sys.stdout.encoding)
ä
 

comments

pekkaklarck wrote Oct 10, 2011 at 1:38 PM

This occurs also with IPY 2.7. Notice that sys.stdout.encoding is cp437 both with IronPython and CPython. Some more experimenting below:


D:>ipy
IronPython 2.7 (2.7.0.40) on .NET 4.0.30319.237
Type "help", "copyright", "credits" or "license" for more information.
import sys
sys.stdout.encoding
'cp437'
a = u'\xe4'.encode(_)
a
u'\x84' # should be just '\x84'
print a
?
^Z
D:>python
Python 2.7 (r27:82525, Jul 4 2010, 09:01:59) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
import sys
sys.stdout.encoding
'cp437'
a = u'\xe4'.encode(_)
a
'\x84'
print a
ä

yYHernan wrote Aug 1, 2012 at 3:46 AM

Same issue still exists in 2.7.3

IronPython 2.7.3 (2.7.0.40) on .NET 4.0.30319.17626 (32-bit)
Type "help", "copyright", "credits" or "license" for more information.
import sys
print u'\xe4'.encode(sys.stdout.encoding)
?
sys.stdout.encoding
'cp437'

yYHernan wrote Aug 1, 2012 at 4:08 AM

Using .Net library within IronPython shows the correct result, see below:
import clr
import System
System.Console.WriteLine(u'\xe4')
ä