Use of Æ, Ø and Å in system.perspective.download

I'm using a script for saving and storing the Alarm Journal to a file. The alarm journal contains the Norwegian letters æ, ø and å. I'm using the system.perspective.download-function to save the file, but I'm not able to force it to store these characters in the file.

The system.perspective.print-function prints these characters fine in the Output Console, so my guess is that the problem is in the system.perspective.download-function. I've tried both the system.dataset.toCSV and .toExcel-conversions before downloading the file. I have also opened both types of files in both Excel and in Notepad++ without any luck.

I've also experimented with the contentType in the download function, but also here without success.


Segment from script:

dataz = system.dataset.toDataSet(header,table)
csvData = system.dataset.toCSV(dataset=dataz)

system.perspective.print(csvData)

system.perspective.download(filename="Label.xls", data=csvData, contentType="text/plain; charset=utf-8")


I'm surely not the first one experiencing this, so I'm wondering if there are anyone out there who can point me in the correct direction?

I have no direct experience, but I suspect that there may be some misalignment between your data and filetype causing the issues rather than Ignition's download function itself. Ultimately, .xls is a legacy Excel binary file extension which may not properly encode plaintext CSV data with such characters. Unless you explicitly need that filetype to interface with some legacy software (pre-2003 ish), I would suggest trying either

  1. Use system.dataset.toExcel to obtain data and save with file extension '.xlsx'
  2. Keep using system.dataset.toCSV and save with file extension '.csv'
    • You may also want to add a UTF-8 BOM to the beginning of your CSV data if you're ultimately planning to open this in Excel since Windows applications are known to interact strangely with non-ASCII plaintext coming from the input text stream unless given explicit instructions.
      • Example: csvData = u'\ufeff' + system.dataset.toCSV(dataz)

I'm mostly commenting because I'm interested to hear how this turns out, actually. Best of luck!