class FFI::Pointer

def read_wstring(num_wchars = nil)


Read null-terminated Unicode strings.
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