[CSVUtil] Show chinese characters in csv

Forge Component
Published on 2019-09-28 by Wei Zhu
27 votes
Published on 2019-09-28 by Wei Zhu


I am trying to output in a CSV file a chinese character. tried changing the "Encoding" parameter in TextToBinaryData function from ; 'big5', 'utf-8' and some other values but no luck. Below is the process flow. I am getting this text "¬QªH¤r" instead of the chinese characters.

Any thoughts?


Hi Deus, 

I tried exporting a record with a chinese character, and it exported fine. The CSV contains the correct data, and it displays correctly in a text-editor, however, Excel does not open the file as UTF-8...

The trick is to prepend the file with a 3-byte ByteOrderMark, but CSVUtil doesn't do that for you. You'll need a forge component BinaryConcat. Then in the inputs to BinaryConcat, the first one will be the BOM-characters (displayed as ASCII chars, do not encode it as utf-8, they should be converted to binary as-is), then the rest of the CSV converted as utf-8. Example below:

These are the 3-bytes to indicate UTF-8

The output of BinaryConcat is what you download as the final csv file. When it opens in Excel it should use UTF-8 encoding.

reference here: https://stackoverflow.com/a/155176