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



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

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

#snapshotObject



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

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