Also, as you point out, ASCII quotation marks should sometimes not be converted to curly quotes at all, but to measurement marks (u+2032 ′ and u+2033 ″), or should occasionally even be retained as ASCII quotation marks, in a passage that's actually discussing something typed.
Some alternative solutions:
- A lot of the software used by book authors for creating text (Scrivener, Ulysses, most word processors) allow converting typed ASCII quotation marks to curly quotes as one types. Such software still faces the same ambiguities as discussed, so it’s up to the author to notice when the software makes the wrong guess (or to learn the cases where the software gets it wrong, and to type something slightly different accordingly, and later do a global search and replace).
- Some input methods built into your windowing system can do the job. iOS has a "smart punctuation" option. X11’s built-in simple input engine can replace chosen strings of key presses with chosen corresponding textual strings (man XCompose).
- Regular expression find-and-replace, using interactive replacement for the ambiguous cases. (This assumes that you have a text editor that allows interactive replacement of regular expressions. Emacs is one such text editor, though it’s somewhat heavy-weight if you haven’t used it before and don’t intend to use it other than for this one task.)
- Whatever method you used to create those em dashes in your post.