Once upon a time, Bill Gates was writing a letter in Microsoft Word, and he pressed the quotes key on his keyboard.  It made a ", and he looked at it, and said "That’s ugly!  I want them to be curlier!  Steve, make it so!".  And so Microsoft made Smart Quotes.  Not really.  But they did make Smart Quotes.

Following is a description of what Smart Quotes are.  If you already know, make sure to scroll to the bottom for a document I think you might find useful.

Smart Quotes are little things that look like quotes and apostrophes, but aren’t really.  They’re certainly more attractive, but they’re simply not plain text.  This means that applications designed to read plain text but not NON-plain text don’t display them.  This is most noticeable on the Internet, when documents are made with Microsoft products, but not viewed with Microsoft products.  It also happens when they’re in a document that is specifically ordered to be a certain kind of text, like UTF-8.  This is also very common on the web.

What’s to be done?  Well, your web document should be fixed.  If it’s a simple document, you can use search and replace, and find the Smart Quotes and replace them either with real quotes, or the HTML Entity tag for them (").

What if the content is in a database?  Wel,l you can still do a search and replace, the SQL is something like this:
UPDATE artist SET artist_blurb = REPLACE(artist_blurb, ”’, ”’) WHERE artist_blurb LIKE ‘%’%’;

The catch for me is that I don’t use Microsoft products on a regular basis, Bill has decided not to make any for my computer.  So that example I just gave doesn’t work, because my browser doesn’t render the things that need to be removed.  I did find however, that Abiword preserves the bogus text, and I can paste it into phpMyAdmin in Firefox, even in Linux.

So here I have for you an abiword document with the queries properly formatted to replace double quotes, single quotes, and the "em" dash, which is a funky double width dash.  Enjoy.

Abiword Document.

2 thoughts on “Microsoft “smart” quotes in MySQL

  1. Topher,

    Vicki noticed this a couple of years ago. I believe she developed a Word Macro that would replace smart quotes with real quotes, so you may want to talk with her as well.


  2. “And so Microsoft made Smart Quotes. Not really. But they did make Smart Quotes.”

    Microsoft did not invent typographically correct quotes. They maybe coined the term ‘Smart Quotes’ when they added that feature to autocorrect, but it wasn’t an MS innovation. Having quote marks curl to the right and left to enclose a quotation is how things are supposed to look (ditto for single quotes curling left or right). The straight double-quote that is on keyboards is not the Right way of doing quotation marks.

    So, where possible, it’s nice to maintain the typographically correct quotes. There are HTML entities that you can use to represent these, and if you encode your document in UTF-8 and send the proper content-type header, modern browsers should be able to figure it out.

    In summary, don’t rid your site of ‘Smart Quotes’–they are your friend.

Leave a Reply

Your email address will not be published. Required fields are marked *