Does anyone know how to specify the character enco...
# suitescript
j
Does anyone know how to specify the character encoding when response.write()-ing a CSV file from a Suitelet? E.g.
Copy code
var file = nlapiCreateFile(filename, 'CSV', csv);
file.setEncoding('windows-1252');
response.setContentType(file.getType(), filename);
response.write(file.getValue());
oh wait let me try
response.setEncoding('windows-1252');
hm
well that changes the encoding but not how I want, lol
just need to be able to deal with
é
and such
b
Copy code
response.write(file);
j
that doesn’t work at all, you just get a file with the contents
nlobjFile
lol
it’s ok I got it working with my solution above
the fun part was setting the encoding conditionally depending on the User-Agent
🙂
b
its pretty weird, but files loaded from the file cabinet can be directly written by responses
files in memory cant
j
gotcha
yeah this will never go in FC, it’s just a file generated on-the-fly
now I need to make the change in my SS2 version, whee
someday I’ll get around to deprecating all our SS1 stuff