summaryrefslogtreecommitdiff
path: root/lib/chef/win32/unicode.rb
diff options
context:
space:
mode:
authorStuart Preston <stuart@chef.io>2018-06-19 11:40:38 +0100
committerStuart Preston <stuart@chef.io>2018-06-19 11:40:38 +0100
commit7b0577496c540c85772fd9284ede3f963337666f (patch)
tree9b9db97c0343ee312c3e05a7def11e54906f3905 /lib/chef/win32/unicode.rb
parentfb7af56751a240bb66de650319375d1eb91460fa (diff)
downloadchef-7b0577496c540c85772fd9284ede3f963337666f.tar.gz
powershell_exec uses FFI instead of COM
Signed-off-by: Stuart Preston <stuart@chef.io>
Diffstat (limited to 'lib/chef/win32/unicode.rb')
-rw-r--r--lib/chef/win32/unicode.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/chef/win32/unicode.rb b/lib/chef/win32/unicode.rb
index dd5a197f71..033569f731 100644
--- a/lib/chef/win32/unicode.rb
+++ b/lib/chef/win32/unicode.rb
@@ -48,6 +48,12 @@ module FFI
wide_to_utf8(get_bytes(0, num_wchars * 2))
end
+
+ def read_utf16string
+ offset = 0
+ offset += 2 while get_bytes(offset, 2) != "\x00\x00"
+ get_bytes(0, offset).force_encoding("utf-16le").encode("utf-8")
+ end
end
end