Get rid of the encode test and iconv fallback

bug/bundler_fix
Tod Beardsley 2015-06-19 12:30:20 -05:00
parent afe5bb54c3
commit a004c72068
No known key found for this signature in database
GPG Key ID: BD63D0A3EA19CAAC
1 changed files with 3 additions and 12 deletions

View File

@ -366,20 +366,11 @@ module Text
end end
# #
# Converts ISO-8859-1 to UTF-8 # Converts US-ASCII and ISO-8859-1 to UTF-8, skipping over
# any characters which don't convert cleanly.
# #
def self.to_utf8(str) def self.to_utf8(str)
str.encode('utf-8', { :invalid => :replace, :undef => :replace, :replace => '' })
if str.respond_to?(:encode)
# Skip over any bytes that fail to convert to UTF-8
return str.encode('utf-8', { :invalid => :replace, :undef => :replace, :replace => '' })
end
begin
Iconv.iconv("utf-8","iso-8859-1", str).join(" ")
rescue
raise ::RuntimeError, "Your installation does not support iconv (needed for utf8 conversion)"
end
end end
# #