Module: RunLoop::Encoding

Included in:
Shell, Xcrun
Defined in:
lib/run_loop/encoding.rb

Defined Under Namespace

Classes: UTF8Error

Instance Method Summary collapse

Instance Method Details

#transliterate(string) ⇒ Object

Removes diacritic markers from string.

The ruby Encoding tools cannot perform this action, they can only change convert one encodign to another by substituting characters.

In ruby 1.9.3 we would have used Iconv, but that does not exist in 2.0.

The Encoding::Convert in 2.0 does not work on string with UTF-16 characters.



13
14
15
16
17
18
19
20
# File 'lib/run_loop/encoding.rb', line 13

def transliterate(string)
			require "i18n"
  locales = I18n.available_locales
  if !locales.include?(:en)
    I18n.available_locales = locales + [:en]
  end
  I18n.transliterate(string)
end