Specifying Encoding While Placing Files In InDesig

2019-08-07 18:08发布

问题:

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?

回答1:

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;
}