Support for special/accentuated characters - jython Fiji

Hi all,
I noticed that printing or using accentuated and special characters with jython scripting yields unexpected results.

It’s not a big deal but can be a headache when writing text to a file for instance.
I think it’s because the default encoding is not UTF-8 for jython.

Fun fact, in ImageJ with jython this prints well (different jython or JVM settings ?).
While in Fiji, with Groovy for instance this also prints correctly.


I tried putting -Dpython.console.encoding=UTF-8 in ImageJ.cfg but it does not seem to fix it.

imagej1 uses this to call Jython:

(I’m not sure where the source for that Jython.jar file can be found. @Wayne can certainly tell.)

On the other hand, SciJava (and therefore Fiji) has scripting-jython which is just a light wrapper around jython.

@LThomas, it will work if you explicitly define your strings as Unicode strings in Python:

print u"é"
print u"ö"
print u"°"
print u"µ"
1 Like

Thanks for the tip ! I knew about raw strings for paths with “r”, always wondered about the “u” :stuck_out_tongue: