Class: Rex::Proto::MsNrtp::MsNrtpCountedString

Inherits:
BinData::Primitive
  • Object
show all
Defined in:
lib/rex/proto/ms_nrtp/ms_nrtp_counted_string.rb

Instance Method Summary collapse

Instance Method Details

#getObject



10
11
12
# File 'lib/rex/proto/ms_nrtp/ms_nrtp_counted_string.rb', line 10

def get
  self.string_data.to_binary_s.force_encoding(self.string_encoding == 0 ? Encoding::UTF_16LE : Encoding::UTF_8)
end

#set(v) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/rex/proto/ms_nrtp/ms_nrtp_counted_string.rb', line 14

def set(v)
  self.string_data = v.bytes
  if v.encoding == Encoding::UTF_16LE
    self.string_encoding = 0
  elsif v.encoding == Encoding::UTF_8
    self.string_encoding = 1
  else
    raise ::EncodingError, 'strings must be UTF-8 or UTF-16'
  end
end