how to save a UTF-8 encoded text file ?
hi People
I have a little script which reads the source text from a layer and saves it to a .txt file. This is on a Mac and all was good until recently when I tried opening the .txt file on a PC in Notepad and found my ˚ degree symbols all whack.
Resaving the .txt file in TextEdit as Unicode (UTF-8) encoding solved the problem, now opens fine in Notepad.
But ideally I'd like the script to output the .txt as UTF-8 in the first place. It's currently Western (Mac OS Roman). I've tryed adding in myfile.encoding = "UTF8" but the resulting file is still Western (and the special charaters have wigged out again)
any help greatly appreciated../daniel
{
var theComp = app.project.activeItem;
var dataRO = theComp.layer("dataRO").sourceText;
// prompt user to save file
var theFile = new File ("~/Desktop/"+ theComp.name + "_output.txt");
theFile = theFile.saveDlg("Save an ASCII export file.");
if (theFile != null) { // check user didn't cancel dialog
theFile.lineFeed = "windows";
//theFile.encoding = "UTF8";
theFile.open("w","TEXT","????");
theFile.writeln("move details:");
theFile.writeln(dataRO.value.toString());
}
theFile.close();
}
