Method: ErlangBitstream#str2int

Defined in:
lib/utils/erlang_parser.rb

#str2int(s, type) ⇒ Object



119
120
121
122
123
124
125
126
127
# File 'lib/utils/erlang_parser.rb', line 119

def str2int(s, type)
  case type
  when 'utf8' then s.encode('utf-8').unpack('C*')
  when 'utf16' then s.encode('utf-16').unpack('C*').drop(2)
  when 'utf32' then s.encode('utf-32').unpack('C*').drop(4)
  when 'integer', 'float' then raise "Cannot handle bit string as type #{type}"
  else s.split('').map { |x| x.ord & 0xff }
  end
end