DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Replace MS Word Smart Quotes With Straight Quotes

08.09.2006
| 11456 views |
  • submit to reddit
        MS Word's smart quotes cause all kinds of problems when pasted into web applications as they're none standard characters. In Ruby, the following works, replacing them with ' and " , which can then be turned into the proper entities with textile etc.

string.gsub! "\342\200\230", "'"
string.gsub! "\342\200\231", "'"
string.gsub! "\342\200\234", '"'
string.gsub! "\342\200\235", '"'

Perhaps someone can implement this in a nicer way.