有没有一种算法可以将撇号 (') 替换为英语短语中的倾斜变体 (' 和 ')?

Is there an algorithm to replace apostrophes (') with their slanted varients (’ and ‘) in an english phrase?

提问人:Alexander 提问时间:11/5/2021 更新时间:11/16/2021 访问量:119

问:

我们得到一个包含撇号()和引号()的任意英语短语。有没有一种算法可以适当地用它们的倾斜变体替换这些字符?'U+0027"U+0022

  • 撇号将变为:'
    • 右单引号 () 或U+2019
    • 左单引号 (U+2018)
  • 引号将变为:"
    • 左双引号 () 或U+201C
    • 右双引号 (U+201D)

我们可以保证输入的英语句子语法正确。

例子:

  • I'm doing great!成为I’m doing great!
  • "Aren't you a little short?"成为“Aren’t you a little short?”
  • "When you said 'Commas don't matter,' I died a little inside."成为“When you said ‘Commas don’t matter,’ I died a little inside.”
字符串 双引号

评论


答:

0赞 Alexander 11/16/2021 #1

事实证明,我一直在寻找聪明的报价。