Apps 脚本 - 如何用普通字符替换 Google 文档中的智能引号字符?

Apps Script - How to replace Smart Quotes characters in Google Docs with normal characters?

我在 Google 文档中遇到与撇号字符相关的智能引号问题。

例如,如果我输入字符串Employee's Name,它将变成Employee’s Name

注意撇号有何不同。

我需要找到一种方法将所有 替换为 ',以及所有其他 "Smart" 使用 Apps 脚本引用的字符

我想这可以通过使用 replace 函数来完成。但是我不知道"what"被替换了。是否有智能引号字符列表?

那么如何解决这个问题呢?谢谢。


注意:我知道我可以通过转到 Tools -> Preferences 并禁用 Use smart quotes 来禁用此功能,但我不能这样做,因为我正在开发一个插件

智能引号将单撇号和双引号替换为其 "smart"(“智能”,而是)等价物。有关所用字符的更多信息 here.

如果您正在使用 Google 文档,您可能需要使用 replaceText(searchPattern, replacement) 功能。请参阅下面使用此函数的示例代码片段:

var body = DocumentApp.getActiveDocument().getBody();

body.replaceText("(‘|’)", "'");
body.replaceText('(“|”)', '"');