Class: RubySMB::Field::Stringz16

Inherits:
BinData::Stringz
  • Object
show all
Defined in:
lib/ruby_smb/field/stringz16.rb

Overview

Represents a NULL-Terminated String in UTF-16

Instance Method Summary collapse

Instance Method Details

#assign(val) ⇒ Object



6
7
8
# File 'lib/ruby_smb/field/stringz16.rb', line 6

def assign(val)
  super(binary_string(val.encode("utf-16le")))
end

#snapshotObject



10
11
12
13
14
15
16
# File 'lib/ruby_smb/field/stringz16.rb', line 10

def snapshot
  # override to always remove trailing zero bytes
  result = _value
  result
  result = trim_and_zero_terminate(result)
  result.chomp("\0\0").force_encoding("utf-16le")
end