from java.io import File from java.lang import String from org.python.core import codecs codecs.setDefaultEncoding('utf-8') # see https://docs.oracle.com/javase/tutorial/i18n/text/string.html from java.nio.charset import Charset print "Charset.defaultCharset()=", Charset.defaultCharset() ss= File("/home/jbf/public_html/i18n/").list() print '=== File(/home/jbf/public_html/i18n/").list() ===' for s in ss: print '=' + s + '=' utf8bytes= String(s).getBytes('UTF-8') utf8bytes= map( int, utf8bytes ) for i in range(len(utf8bytes)): if utf8bytes[i]<0: utf8bytes[i]=utf8bytes[i]+256 print ' '.join( map( str, utf8bytes ) ), ' (UTF-8)' defbytes= String(s).getBytes() defbytes= map( int, defbytes ) for i in range(len(defbytes)): if defbytes[i]<0: defbytes[i]=defbytes[i]+256 print ' '.join( map( str, defbytes ) ), ' (default)'