I’m trying to generate an Excel file with report at the end of the process. I’m using Python and XlsxWriter module.
The problem that I encountered is that when I run the script directly from any IDE the encoding is proper:
However when I run the same script from Workflow process encoding of texts is wrong:
I tried several tricks found in google like using encode() function, changing locale with setlocale() or following these recommendation: excel - How to write German umlauts to a spreadsheet with xlsxwriter in Python - Stack Overflow but nothing worked for me. When I checked both
sys.getdefaultencoding() and locale.getlocale() both from IDE and Workflow they show the same values:
utf-8 and (‘Polish_Poland’, ‘1252’).
Did anyone encountered similar problem? I’m slowly getting out of ideas at the moment.
Yes, later I tried to use External Program plugin and in this case everything works fine.
It seems that Workflow has problems with reading strings, which are entered directly in code in py file specified as the script to run in Run Script properties. If this file reads more strings from another py file, or from some other resource like database, those strings are displayed correctly.
I suspect, that Workflow reads the first py file using wrong encoding, hence wrong characters, but all later files are read by Python interpreter itself, which handles UTF-8 encoding correctly.