Sha256: 3de070519a4442d4b1e15d4bb1f4751a6b641313d8cdb53ffff96ca2d7ced184
Contents?: true
Size: 1.39 KB
Versions: 43
Compression:
Stored size: 1.39 KB
Contents
module RunLoop module Encoding # Removes diacritic markers from string. # # The ruby Encoding tools cannot perform this action, they can only change # convert one encoding 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. def transliterate(string) require "i18n" locales = I18n.available_locales if !locales.include?(:en) I18n.available_locales = locales + [:en] end I18n.transliterate(string) end # Raised when a string cannot be coerced to UTF8 class UTF8Error < RuntimeError; end # @!visibility private def ensure_command_output_utf8(string, command) return '' if !string utf8 = string.force_encoding("UTF-8").chomp return utf8 if utf8.valid_encoding? encoded = utf8.encode("UTF-8", "UTF-8", invalid: :replace, undef: :replace, replace: "") return encoded if encoded.valid_encoding? raise UTF8Error, %Q{ Could not force UTF-8 encoding on this string: #{string} which is the output of this command: #{command} Please file an issue with a stacktrace and the text of this error. https://github.com/calabash/run_loop/issues } end end end
Version data entries
43 entries across 43 versions & 1 rubygems