ANS-0934 · SUITESCRIPT DEVELOPMENT

How to Export CSV Files with Accented Characters in NetSuite SuiteScript?

Ensure proper character display in CSV exports by specifying the correct file encoding in NetSuite SuiteScript.

Short answer

To preserve accented characters when exporting CSV files in NetSuite SuiteScript, specify the 'windows-1252' encoding during file creation. This ensures that special characters are correctly rendered in the generated CSV, preventing data corruption or display issues.

Scenario

Users exporting CSV files from NetSuite via SuiteScript may encounter issues where accented characters or other special symbols are not displayed correctly in the generated file. This typically results in corrupted or unreadable characters, indicating a problem with the file's character encoding.

Solution

To ensure that accented characters are preserved when exporting CSV files using SuiteScript, it is essential to specify the correct character encoding during file creation. The 'windows-1252' encoding is effective for this purpose. In SuiteScript 2.x, this is achieved using the N/file module as follows:n

javascriptnvar fileModule = require('N/file');nvar newFile = fileModule.create({n    name: 'name.csv',n    fileType: fileModule.Type.CSV,n    contents: csvContent,n    encoding: fileModule.Encoding.WINDOWS_1252n});n

This approach ensures that accented characters are correctly maintained within the generated CSV file.

Expert NetSuite Support

Need help with this NetSuite issue?

SuiteScript Development consulting and configuration support

Talk to a consultant