Ideas for converting straight quotes to curly quotes

前端 未结 9 2000
星月不相逢
星月不相逢 2021-02-07 16:40

I have a file that contains \"straight\" (normal, ASCII) quotes, and I\'m trying to convert them to real quotation mark glyphs (“curly” quotes, U+2018 to U+201D). Since the tran

相关标签:
9条回答
  • 2021-02-07 17:21

    I hate to say it, but the best course of action might be to study what Word does, and copy it. Even if it's wrong in some cases, it represents a standard that many people have become accustomed to. One behavior to emulate is having undo (Ctrl-Z) immediately revert to the straight quote after you have substituted a curved one.

    0 讨论(0)
  • 2021-02-07 17:24

    A good place to start would be with a state machine:

    • Starting at position 0, iterate over the characters
    • Upon finding a quote, enter the "Quoted" state ( open quote )
    • If in "Quoted" state and you encounter a quote, return to "Starting" state ( closing quote )

    You can make additional decisions at each of the state transitions.

    You could attempt to normalize the single quotes by identifying known conjunctions, for instance, and converting them to a different, not text, character prior to processing.

    My $0.02

    0 讨论(0)
  • 2021-02-07 17:24

    Try Shift + Ctrl + " (double quote key), this worked for me on windows 10, using a program called Kalipso.

    0 讨论(0)
提交回复
热议问题