Message5669
With CPython 2.6 on Ubuntu I can do:
args = [ unicode(a, sys.getfilesystemencoding()) for a in sys.argv[1:] ]
but on Jython 2.5.1 that fails with error:
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe5 in position 0: ordinal not in range(128)
The failure is most likely caused by sys.getfilesystemencoding() returning None on Jython when on CPython it returns correctly UTF-8. The differences don't end there, though, as the arguments are got in different format too:
$ python -c "import sys; print sys.argv[1:]" ä €
['\xc3\xa4', '\xe2\x82\xac']
$ jython -c "import sys; print sys.argv[1:]" ä €
['\xe4', '\u20ac']
The bytes Jython gets would actually be correct without decoding if their type would be unicode and not str. In this format they cannot be used directly:
$ jython -c "import sys; print sys.argv[1] + u'\xe4'" ä
Traceback (most recent call last):
File "<string>", line 1, in <module>
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe4 in position 0: ordinal not in range(128) |
|
Date |
User |
Action |
Args |
2010-04-11 21:52:20 | pekka.klarck | set | recipients:
+ pekka.klarck |
2010-04-11 21:52:20 | pekka.klarck | set | messageid: <1271022740.16.0.789683200408.issue1592@psf.upfronthosting.co.za> |
2010-04-11 21:52:20 | pekka.klarck | link | issue1592 messages |
2010-04-11 21:52:18 | pekka.klarck | create | |
|