Skip to content

Commit 04125c7

Browse files
committed
Correctly encode to UTF-8 when possible
1 parent a83fb32 commit 04125c7

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/net/ber.rb

+5-2
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,11 @@ def to_arr
296296
class Net::BER::BerIdentifiedString < String
297297
attr_accessor :ber_identifier
298298
def initialize args
299-
args.force_encoding('UTF-8') if args.respond_to(:force_encoding)
300-
super args
299+
super begin
300+
args.respond_to?(:encode) ? args.encode('UTF-8') : args
301+
rescue
302+
args
303+
end
301304
end
302305
end
303306

0 commit comments

Comments
 (0)