I have the following string:
Your résumé’s a non–encyclopædia
Note the ’, é and æ are non-ascii. I want to leave é and æ intact, but replace the ’ with ascii quote: '.
How can I make such conversion in Ruby (not Rails)? My database is UTF8 and I still wanna store the accented characters, including kanjis, Chinese, etc., but just wanna replace the punctuation.
Found this gem that works exactly what I wanted - https://github.com/qwuen/punctuate
Just do .punctuate!
:
irb(main):001:0> require 'punctuate'
=> true
irb(main):002:0> "Your résumé’s a non–encyclopædia".punctuate!
=> "Your résumé's a non-encyclopædia"