Message3793

Author jcflack
Recipients jcflack
Date 2008-11-20.17:03:27
SpamBayes Score 2.1266433e-09
Marked as misclassified No
Message-id <1227200608.2.0.881326588022.issue1177@psf.upfronthosting.co.za>
In-reply-to
Content
This works in CPython:

Python 2.5.1 (r251:54863, May 23 2007, 10:45:02) 
[GCC 4.1.1] on sunos5
Type "help", "copyright", "credits" or "license" for more information.
>>> import codecs
>>> w = codecs.open('foo','w','utf-8')
>>> w.write(unichr(192))
>>>

It works in Jython 2.2.1:

Jython 2.2.1 on java1.6.0_07
Type "copyright", "credits" or "license" for more information.
>>> import codecs
>>> w = codecs.open('foo','w','utf-8')
>>> w.write(unichr(192))
>>>

But not in 2.5b0:

Jython 2.5b0 (trunk:5540, Oct 31 2008, 13:55:41) 
[Java HotSpot(TM) Server VM (Sun Microsystems Inc.)] on java1.6.0_07
Type "help", "copyright", "credits" or "license" for more information.
>>> import codecs
>>> w = codecs.open('foo','w','utf-8')
>>> w.write(unichr(192))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/.../jython2.5b0/jython-complete.jar/Lib/codecs.py", line 638,
in write
  File "/.../jython2.5b0/jython-complete.jar/Lib/codecs.py", line 304,
in write
UnicodeEncodeError: 'ascii' codec can't encode characters in position
0-1: ordinal not in range(128)

Hmm ... did I somehow get an ascii codec even though I asked for utf-8?
History
Date User Action Args
2008-11-20 17:03:28jcflacksetrecipients: + jcflack
2008-11-20 17:03:28jcflacksetmessageid: <1227200608.2.0.881326588022.issue1177@psf.upfronthosting.co.za>
2008-11-20 17:03:28jcflacklinkissue1177 messages
2008-11-20 17:03:27jcflackcreate