Class: FFI::Pointer

Inherits:
Object show all
Defined in:
lib/chef/win32/unicode.rb

Instance Method Summary collapse

Instance Method Details

#read_wstring(num_wchars = nil) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/chef/win32/unicode.rb', line 33

def read_wstring(num_wchars = nil)
  if num_wchars.nil?
    # Find the length of the string
    length = 0
    last_char = nil
    while last_char != "\000\000" do
      length += 1
      last_char = self.get_bytes(0,length * 2)[-2..-1]
    end

    num_wchars = length
  end

  Chef::ReservedNames::Win32::Unicode.wide_to_utf8(self.get_bytes(0, num_wchars*2))
end