Class: Bytepack::String

Inherits:
Varbinary show all
Defined in:
lib/bytepack/basic/string.rb

Constant Summary

Constants inherited from Varbinary

Varbinary::DIRECTIVE, Varbinary::LENGTH_TYPE, Varbinary::NULL_INDICATOR

Class Method Summary collapse

Methods inherited from Varbinary

pack

Methods inherited from Basic

bytesToInt, intToBytes, preprocess

Methods inherited from Struct

classifyDataType, config, packingDataType, single_type_array?, testpacking

Class Method Details

.convert_input(val) ⇒ Object



11
12
13
# File 'lib/bytepack/basic/string.rb', line 11

def convert_input(val)
  val.to_s.encode("utf-8")
end

.unpack(bytes, offset = 0) ⇒ Object



5
6
7
8
9
# File 'lib/bytepack/basic/string.rb', line 5

def unpack(bytes, offset = 0)
  vb = super(bytes, offset)
  vb[0] = vb[0].force_encoding("utf-8") unless vb[0].nil?
  vb
end