diff --git a/rt_client.rb b/rt_client.rb index 815042c..d5d4b11 100755 --- a/rt_client.rb +++ b/rt_client.rb @@ -879,7 +879,7 @@ def compose(fields) # :nodoc: # Helper to replace control characters with string representations # When some XML libraries hit these in an XML response, bad things happen. def sterilize(str) - str.encode!('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '') + str.encode!('UTF-8', str.encoding.to_s, invalid: :replace, undef: :replace, replace: '') str.gsub!(0x00.chr,'[NUL]') str.gsub!(0x01.chr,'[SOH]') str.gsub!(0x02.chr,'[STX]')