Message6779

Author pekka.klarck
Recipients pekka.klarck
Date 2012-02-13.07:37:36
SpamBayes Score 1.27509e-11
Marked as misclassified No
Message-id <1329118657.14.0.748213526111.issue1839@psf.upfronthosting.co.za>
In-reply-to
Content
With Jython 2.5.2 and earlier sys.getfilesystemencoding() always returns None. This breaks code that tries to encode or decode strings on system boundary. Example uses include decoding received command line arguments or encoding/decoding set/get environment variables. Working sys.getfilesystemencoding() could apparently also fix os.stat on Windows (issue #1658).

I have tested that at least on Ubuntu Linux and WinXP with Western locale the value returned by java.lang.System.getProperty('file.encoding') seems to be correct encoding to use. On Ubuntu I get UTF-8 both with that approach and with Python using sys.getfilesystemencoding(). On Windows file.encoding is Cp1252 and sys.getfilesystemencoding() on Python returns mbcs. Both of these are fine as the former is the actual encoding and the latter a special encoding that the operating system later translates to the correct encoding. Notice also that Jython doesn't support mbcs.

Based on my experimentation I propose sys.getfilesystemencoding() is implemented using java.lang.System.getProperty('file.encoding').
History
Date User Action Args
2012-02-13 07:37:37pekka.klarcksetrecipients: + pekka.klarck
2012-02-13 07:37:37pekka.klarcksetmessageid: <1329118657.14.0.748213526111.issue1839@psf.upfronthosting.co.za>
2012-02-13 07:37:37pekka.klarcklinkissue1839 messages
2012-02-13 07:37:36pekka.klarckcreate