Class: Win32::Registry

Inherits:
Object
  • Object
show all
Defined in:
lib/chef/monkey_patches/win32/registry.rb

Defined Under Namespace

Modules: API

Instance Method Summary collapse

Instance Method Details

#export_string(str, enc = Encoding.default_internal || "utf-8") ⇒ Object

::Win32::Registry#export_string is used when enumerating child keys and values and re encodes a UTF-16LE to the local codepage. This can result in encoding incompatibilities if the native codepage does not support the characters in the registry. There is an open bug in ruby at https://bugs.ruby-lang.org/issues/11410. Rather than converting the UTF-16LE originally returned by the win32 api, we encode to UTF-8 which will likely not result in any conversion error.



32
33
34
# File 'lib/chef/monkey_patches/win32/registry.rb', line 32

def export_string(str, enc = Encoding.default_internal || "utf-8")
  str.encode(enc)
end