I have a script that takes the contents of the clipboard and writes them to a file so that I can paste the content into InDesign. It was working earlier but now it is replacing all the quotes with these characters, "”". I'll paste the before and after:
Before:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <?aid type="snippet" readerVersion="6.0" featureSet="257" product="8.0(370)" ?> <?aid SnippetType="PageItem"?> <Document LinkedSpreads="" DOMVersion="8.0" Self="d"> </Document> After:
<?xml version=”1.0” encoding=”UTF-8” standalone=”yes”?> <?aid style=”50” type=”snippet” readerVersion=”6.0” featureSet=”257” product=”8.0(370)” ?> <?aid SnippetType=”PageItem”?> <Document LinkedSpreads=”” DOMVersion=”8.0” Self=”d”> </Document> I normally can tell if my code changes things but I think I may have changed something in InDesign? I'm going back through my changes to see if it's something I did but in the mean time has anyone seen this?
If I paste the code into a .idms file and then place the document it continues to work. It's the script that is having issues.
11 Answer
I'm not sure what it was but I did not set the file encoding to "UTF-8" and it appears to be working now. Here is a snippet of the code I'm using:
doc.textPreferences.typographersQuotes = false; var tf = doc.textFrames.add(); var story = tf.parentStory; //story.appliedLanguage = app.languagesWithVendors[0]; story.insertionPoints[0].select(); app.paste(); var str = story.contents; if (str.indexOf("‚Äú")!=-1 || str.indexOf("Äù")!=-1) { alert("Weird quotes found. Try saving to an .idms file and then placing it."); //str = str.replace("‚Äù", '"'); //alert(str.substr(0,200)); } tf.remove(); var f = File(Folder.temp + "/temp_snippet.idms"); //f.encoding = "UTF-8"; // commented out here f.open('w'); But I have since uncommented that line again and it's still working. Gremlins.
Update: it stopped working. Then it started working again. Then stopped. All without modifying the import code. It continues to work if I save it to an IDMS text file first rather than copy it to the clipboard.
2