Copy link to clipboard
Copied
Hi folks, having some issues with encoding some information I am getting from a scriptUI in Indesign into a dialog box. myDialogLine in the script below is taking several user inputs, including from a dropdown and some editboxes, and is trying to write the result to an existing text file. The new line is coming in in Chinese characters, even though the inputs are all English. The client's text file is slugged UTF 16.
I will admit to not understanding a great deal about encoding. Anyone have some tips or pointers to troubleshoot this one? Thanks in advance. Here's the snippet where I'm writing to file.
the_link.open('a');
the_link.encoding = "UTF-8";
the_link.writeln(myDialogLine);
the_link.close();
I don't know the API you are using but I can tell you that UTF-16 and UTF-8 are utterly different and not interchangeable. Seeing "Chinese" is likely, but worse could happen. You either have to tell the API to use UTF-16, if it can (check the documentation), or convert the data.
Copy link to clipboard
Copied
Hi Brian,
Can you provide a sample data that you are not able to write into a text file. I can try and see if i can resolve it
-Manan
Copy link to clipboard
Copied
Thanks, Manan,
The data basically follows this: XXX XXXXXXXX XXX \t XXXX \r
Copy link to clipboard
Copied
I don't know the API you are using but I can tell you that UTF-16 and UTF-8 are utterly different and not interchangeable. Seeing "Chinese" is likely, but worse could happen. You either have to tell the API to use UTF-16, if it can (check the documentation), or convert the data.
Copy link to clipboard
Copied
Thanks, and good point. I was trying to open the file as UTF-16, and had switched to UTF-8 to troubleshoot. This is using Extendscript, in which documenation is lacking. Any suggestions on converting a Javascript string to UTF16?