Login
Theme: Light Dark

How do I change unicode encoding to human readable characters in Ruby 2.0+ ? (for ç, à, é, £ etc…)

Tagged:

Home - Quora Link

They already are human readable. What you seem to want is ASCII transliteration.

You can use ActiveSupport::Inflector. Here’s a documentation link:

transliterate (ActiveSupport::Inflector) - APIdock

ActiveSupport is included in any Rails codebase, but you don’t need Rails to use ActiveSupport methods. To use it outside of Rails, do the following.

  1. require 'active_support/inflector' 
  2. ActiveSupport::Inflector.transliterate('Äußerungen') 
  3. # => "Ausserungen" 

Make sure you have ActiveSupport in your Gemfile or installed, of course. The documentation shows how you can define your own transliteration rules if you don’t like what it’s doing.