Page 1 of 1

Save new file as UTF-8

Posted: Mon Sep 07, 2020 1:33 pm
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

Re: Save new file as UTF-8

Posted: Tue Sep 08, 2020 10:21 am
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