I've been trying to use JPython nodes to do some operations on strings but I run into problems with non-ascii characters. The following error shows up in the logs, when trying to cast a string from the table to Unicode:
UnicodeError: ascii decoding error: ordinal not in range(128)
I attach a very simple three-node workflow to show the problem:
Workflow zip file:
First there is a
Table Creator node to create a 1x1 table with a non-ascii string (e.g. làlà lóló lülü çeçe ñiñi). Then there are two
JPython Script 1:1 nodes, the top one just shows the type of the string object when passed to JPython, which is
javainstance. The node at the bottom tries to convert the content of the cell to Unicode when the aforementioned error is trhown.
This is the code:
iterator = inData0.iterator()
row = iterator.next()
cell_01 = row.getCell(0)
# Both the following lines result in the same error
cell_01_unicode = unicode(cell_01)
cell_01_unicode = unicode(cell_01.toString())
Hope someone can help. Thanks!