Save new file as UTF-8

Post Reply
Qpdv
Member
Posts: 22
Joined: Thu Dec 03, 2015 2:59 pm

Save new file as UTF-8

Post by Qpdv »

I've got the following script to convert all semicolons to commas:

Code: Select all

function jobArrived( s : Switch, job : Job)
{	
   	var tempFile = job.createPathWithExtension(job.getExtension());
   	var myFile = new File(tempFile);
   	var InputPath = job.getPath();
   	var inputFileText = File.read(InputPath, "UTF-8");
   	var outputFileText = inputFileText.replace(/;/g, ',');
	myFile.open( File.WriteOnly | File.Truncate );
   	myFile.write(outputFileText);
   	myFile.close();
   	job.sendToSingle(tempFile);
	job.sendToNull(job.getPath());
}
But how can i save the file as UTF-8 (because of the chars like ë etc).
Now it gets saved as ANSI. Which InDesign doesn't like

Thanks in advance,

Peter
dasswill
Newbie
Posts: 1
Joined: Fri Jun 17, 2011 10:12 am

Re: Save new file as UTF-8

Post by dasswill »

You can add the codec to the constructor and the file will save as "UTF-8".

Code: Select all

var myFile = new File(tempFile, "UTF-8");
Best regards,
Daniel
Post Reply