View Full Version : Single-quote/Double-quote


Rand Brittain
08-16-2011, 07:25 PM
Could someone tell me the simplest tool these days for replacing British-style single-quotes with American-style double-quotes?

pholy
08-16-2011, 08:16 PM
The simplest tool, but neither fast nor reliable, is a text editor and your eyeballs and fingertips... :D

To be more useful... What kind of text file do you have? Is it 7-bit ASCII or UTF-8? Is it html or xhtml? And, most importantly, is the apostrophe character the same as the right quote? If not, then a simple character substitution would work. However, they are usually the same, so something more sophisticated is required.

I use quoter to change straight quotes to curly quotes in my html, and straight apostrophes to right single quotes. I don't know if it will do single quotes to double quotes, however. I found it with google, and it is supplied as a lex/yacc source, so it could be modified, I suppose.

charleski
08-16-2011, 10:20 PM
Do you have a link for the code for quoter? I know of SmartyPants from Daring Fireball, but would be interested to see some other code that did the same thing.

Rand Brittain
08-16-2011, 11:16 PM
The file in question is an epub. As far as I can see, the single quote and apostrophe are the same; both curly, I'm afraid.

Jellby
08-17-2011, 04:34 AM
I wouldn't trust anything automatic, this is what I'd do:

1. Replace every left-single with "" (or any otherwise unused character)
2. For every "", find the matching right-single (not apostrophe), and replace it with "|" (or other)
3. Replace every remaining right-single (apostrophes) with "" (or other)
4. Replace every left-double with left-single, and right-double with right-single.
5. Replace every "" with left-double, and "|" with right-double.
6. Replace every "" with something different from right-single, but which displays the same (for instance, "& #8217;", without space and quotes).

HarryT
08-17-2011, 05:17 AM
I would regard the quoting style as a part of the book, and wouldn't change it, personally.

Jellby
08-17-2011, 06:15 AM
But maybe someone has changed it before ;)

pholy
08-17-2011, 02:19 PM
Do you have a link for the code for quoter? I know of SmartyPants from Daring Fireball, but would be interested to see some other code that did the same thing.

Ahhh, found it. Second page of google; I thought it would show up sooner:

http://www.dwheeler.com/quoter/

sjkramer
08-22-2011, 01:28 PM
I would regard the quoting style as a part of the book, and wouldn't change it, personally.

It's interesting that The Chicago Manual of Style (the publishing industry standard style guide) includes changing quote style in its very limited list of acceptable alterations to a text.

carmenchu
09-01-2011, 12:34 PM
Alternate option:
in Sigil/Notepad++ or other software allowing RegExp search/replace mode, and in that mode:
1. replace ([a-z])'([a-z]) with \1<unused char/string>\2 -- almost every apostrophe "escaped" to the <unused char/string> of your choice
2. check for expression like " 'em " in your text, at need, replace each of them with " <unused char/string>em " ...
Now, in normal Mode:
3. Follow Jellby 's previous post to switch " and '
4. Restore <unused char/string> to ' .

If right quote/apostrophe are curly, steep 2. is only for those.