Module: RubyHome::TLV::Utf8

Extended by:
Utf8
Included in:
Utf8
Defined in:
lib/ruby_home/tlv/utf8.rb

Instance Method Summary collapse

Instance Method Details

#pack(input) ⇒ Object



6
7
8
# File 'lib/ruby_home/tlv/utf8.rb', line 6

def pack(input)
  input.bytes.map { |b| b.to_s(16) }.join
end

#unpack(input) ⇒ Object



10
11
12
13
14
15
# File 'lib/ruby_home/tlv/utf8.rb', line 10

def unpack(input)
  [input]
    .pack('H*')
    .force_encoding('utf-8')
    .encode('utf-8')
end