How to fix jython to print unicode correctly in apple's Terminal.app
and iTerm, the two predominant terminal applications on the mac-- Maybe
something like this should be the default on OS X?
import sys
from string import atoi
from java.lang import System
from java.io import PrintStream
if System.getProperty("os.name")=="Mac OS X":
System.setOut(PrintStream(System.out, 1, "UTF-8"));
class encoder:
def write(self, text):
System.out.write(text.encode("utf-8", "replace"))
sys.stdout = encoder()
Note that using System.out in the python encoder is required, as
sys.out messes up the output.
|