Class: FFI::Pointer

Inherits:
Object
  • Object
show all
Includes:
Win32::Certstore::Mixin::String
Defined in:
lib/win32/certstore/mixin/unicode.rb

Instance Method Summary collapse

Methods included from Win32::Certstore::Mixin::String

#utf8_to_wide, #wide_to_utf8, #wstring

Instance Method Details

#read_wstring(num_wchars = nil) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/win32/certstore/mixin/unicode.rb', line 27

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"
      length += 1
      last_char = get_bytes(0, length * 2)[-2..-1]
    end

    num_wchars = length
  end
  wide_to_utf8(get_bytes(0, num_wchars * 2))
end