NetSuite 2.0: Garbled characters appear when reading csv-type files in the file cabinet

The specific code is as follows.

const fileObj = file.load({
  id: 6678,
return fileObj.getContents();

The returned result is garbled. Now I am basically a beginner and I don’t know how to deal with this problem.The returned result is this form: �ڲ���ʶ,�ۺϼƻ�ʱ��,�Ƿ��ݻ�,������������,���ţ��޲㼶��,�ص�,ERP���۶�����,������Ŀ��.

Have you encountered this problem? How did you solve it? Please tell me how to solve it, thank you very much!

Rookie Asked on January 6, 2021 in SuiteScript.
Add Comment
1 Answer(s)
Best answer

Whats it supposed to be? The string is full of encoding errors, which suggests that the file was created with the wrong encoding.

Intermediate Answered on January 6, 2021.

Thank you, how should the encoding of the incoming file be set? Now when you open the file directly, you can see that it is Chinese characters. If you can get it with a script, there will be messy codes.

on January 6, 2021.

The basic lesson is that files are a sequence of bytes. There are different ways of changing these bytes into the characters you see on the screen, these are encodings. Whatever is interpreting the files picks an encoding to show you its contents. pick the wrong one and you get the encoding errors you see.

Ideally you figure out which encoding is used by whatever you are using to generate your file, then choose that encoding when you upload the file. Alternativly you can keep on guessing until you find the correct encoding

Another alternative is that the default encoding is probably UTF-8, so make sure that your input file is UTF-8

on January 8, 2021.

Thanks for your help, I will try your way.

on January 10, 2021.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.
  • This site made possible by our sponsors:   Tipalti   Celigo   Limebox   Become a Sponsor