本文介绍了从剪贴板粘贴到InDesign时获取奇怪的字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个脚本,该脚本接收剪贴板的内容并将其写入文件,以便可以将内容粘贴到InDesign中。它以前工作正常,但现在将所有引号替换为这些字符,Äù。我将粘贴之前和之后:

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:

之前:

<?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>

之后:

<?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>

我通常可以判断我的代码是否更改了某些内容,但是我想我可能已经在InDesign中进行了更改?我将重新进行更改以查看是否做了我的操作,但与此同时有人看到了吗?

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?

如果我将代码粘贴到.idms文件中,然后将其放置在文档中,它将继续起作用。脚本出了问题。

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.

推荐答案

我不确定是什么,但是我没有将文件编码设置为 UTF-8现在开始工作。这是我正在使用的代码段:

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.

这里是完整的脚本,。

这篇关于从剪贴板粘贴到InDesign时获取奇怪的字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 00:30