class String

Public Instance Methods

wincode() click to toggle source

Convenience method for converting strings to UTF-16LE for wide character functions that require it.

# File lib/win32/dir/functions.rb, line 56
def wincode
  (tr(File::SEPARATOR, File::ALT_SEPARATOR) + 0.chr).encode("UTF-16LE")
end
wstrip() click to toggle source

Read a wide character string up until the first double null, and delete any remaining null characters.

# File lib/win32/dir/functions.rb, line 62
def wstrip
  force_encoding("UTF-16LE").encode("UTF-8", invalid: :replace, undef: :replace)
    .split("\x00")[0].encode(Encoding.default_external)
end