Class: RangeScan::Utils

Inherits:
Object
  • Object
show all
Defined in:
lib/rangescan/utils.rb

Class Method Summary collapse

Class Method Details

.to_utf8(obj) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/rangescan/utils.rb', line 6

def to_utf8(obj)
  return obj.dup.force_encoding(Encoding::UTF_8) if obj.is_a?(String)

  obj.map do |k, v|
    k = k.dup.force_encoding(Encoding::UTF_8) if k.is_a?(String)
    v = v.dup.force_encoding(Encoding::UTF_8) if v.is_a?(String)
    [k, v]
  end.to_h
end