class FFI::Pointer
def read_wide_string(num_bytes = size)
then an empty string is returned instead.
If this fails (typically because there are only null characters)
Read +num_bytes+ from a wide character string pointer.
def read_wide_string(num_bytes = size) read_bytes(num_bytes).force_encoding("UTF-16LE") .encode("UTF-8", invalid: :replace, undef: :replace) .split(0.chr).first.force_encoding(Encoding.default_external) rescue "" end