1

I have a script that places a Markdown file into a text frame in InDesign. Unfortunately, InDesign doesn't seem to be picking up on the UTF-8 encoding, as quotation marks and other things are ending up as “.

I tried setting file.encoding to "UTF-8" based on this question, all to no avail. Here's the relevant code as it stands:

var file = File.openDialog ("Select content markdown" , "Markdown:*.md", false );
file.encoding = "UTF-8";
myFirstTextframe.place(file);

How can I resolve this problem?

Community
  • 1
  • 1
Nathan Arthur
  • 8,287
  • 7
  • 55
  • 80
  • Try to find out what InDesign's automatic file recognition thinks it is: `myFirstTextframe.place(file, true);` will show the Import Text Options. – Jongware Jun 11 '15 at 22:12
  • @Jongware Hmm. It's saying Macintosh Roman. Manually selecting Unicode UTF8 in that dialog does work, if clumsily. – Nathan Arthur Jun 12 '15 at 14:26

1 Answers1

5

I'm not 100% sure (perhaps InDesign is just remembering what I selected in the Import Options window), but it seems like adding this solved my problem:

with(app.textImportPreferences){
    characterSet = TextImportCharacterSet.UTF8;
    useTypographersQuotes = true;
}
Nathan Arthur
  • 8,287
  • 7
  • 55
  • 80