Special Non-English Character Issue in downloaded csv files using system.perspective.download

Hello Team,
we are facing some issue when opening downloaded csv files (data read from SQL DB) using system.perspective.download that contain Non-English special characters.
The characters are not correctly denoted after the csv file is opened.
Need some solution or alternative suggestion on the issue.

Thank You

You need to figure out where the problem is: in the database or in the Ignition read and download.

When you look in the database directly is the encoding correct?

Which database type are you using?
What character encoding are you expecting?

In Database the characters are shown correctly also there is no error when we read into ignition using system.dataset.toCsv method , only issue occurs when we open that file in microsoft excel.
We require ANSI encoding. Currently it is UTF-8 encoding.

These two requirements are fundamentally incompatible. ANSI doesn't have many (any?) non-english characters.

2 Likes

Is the file used elsewhere and you really need ANSI, or are you just opening it in Excel? If the latter, you'll need to add a byte-order marker to the file:

csvData = u'\xef\xbb\xbf' + system.dataset.toCSV(dataset)
1 Like

What does the '\xef\xbb\xbf' mean on the snip of code?

Do you mean the \xef and similar escape sequences? Described here:

https://docs.python.org/2.7/reference/lexical_analysis.html#string-literals

Or do you mean the Byte Order Mark itself?

ANSI is a collection of multiple encodings(GB2312、GBK、GB18030、Big5、Shift_JIS and so on), and different languages correspond to different encodings.
I did a little test. I created a GB2312 (ANSI for Simplified Chinese) txt file and opened it with Notepad. Then it shows that the encoding is ANSI. Therefore, the Simplified Chinese Windows operating system thinks that GB2312 is ANSI.
For ANSI users of other languages, I think setting the encoding to the corresponding language's encoding should do the trick.