Skip to content

Commit a004c72

Browse files
author
Tod Beardsley
committed
Get rid of the encode test and iconv fallback
1 parent afe5bb5 commit a004c72

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

lib/rex/text.rb

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -366,20 +366,11 @@ def self.to_raw(str)
366366
end
367367

368368
#
369-
# Converts ISO-8859-1 to UTF-8
369+
# Converts US-ASCII and ISO-8859-1 to UTF-8, skipping over
370+
# any characters which don't convert cleanly.
370371
#
371372
def self.to_utf8(str)
372-
373-
if str.respond_to?(:encode)
374-
# Skip over any bytes that fail to convert to UTF-8
375-
return str.encode('utf-8', { :invalid => :replace, :undef => :replace, :replace => '' })
376-
end
377-
378-
begin
379-
Iconv.iconv("utf-8","iso-8859-1", str).join(" ")
380-
rescue
381-
raise ::RuntimeError, "Your installation does not support iconv (needed for utf8 conversion)"
382-
end
373+
str.encode('utf-8', { :invalid => :replace, :undef => :replace, :replace => '' })
383374
end
384375

385376
#

0 commit comments

Comments
 (0)