From: <pj...@us...> - 2009-04-11 21:27:38
|
Revision: 6220 http://jython.svn.sourceforge.net/jython/?rev=6220&view=rev Author: pjenvey Date: 2009-04-11 21:27:36 +0000 (Sat, 11 Apr 2009) Log Message: ----------- encode unicode printed to file objects per the file's encoding Modified Paths: -------------- trunk/jython/src/org/python/core/StdoutWrapper.java Modified: trunk/jython/src/org/python/core/StdoutWrapper.java =================================================================== --- trunk/jython/src/org/python/core/StdoutWrapper.java 2009-04-11 20:49:13 UTC (rev 6219) +++ trunk/jython/src/org/python/core/StdoutWrapper.java 2009-04-11 21:27:36 UTC (rev 6220) @@ -105,8 +105,14 @@ file.write(" "); file.softspace = false; } - PyString string = o.__str__(); - String s = string.toString(); + + String s; + if (o instanceof PyUnicode && file.encoding != null) { + s = ((PyUnicode)o).encode(file.encoding, "strict"); + } else { + s = o.__str__().toString(); + } + int len = s.length(); file.write(s); if (o instanceof PyString) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |