puppetlabs/puppet — pull request #2229 by joshcooper (2014-01-07 23:05:03+00:00)
Title: (PUP-1281) Force registry value encoding to match code page

Ruby uses ANSI versions of Win32 APIs to read values from the registry. The
encoding of these strings depends on the active code page. However, ruby
incorrectly sets the string encoding to US-ASCII.[1]

As a result, if you try to perform a regex match on the string, and the string
contains the registered trademark symbol ®, then ruby will raise an error
saying 'Invalid byte sequence in US-ASCII'

This commit forces the encoding of `REG_SZ`, `REG_EXPAND_SZ`, and `REG_MULTI_SZ` to
the encoding for the active code page. So if the active code page is 1252, the
ruby encoding will be `Encoding::CP1252`.

See https://bugs.ruby-lang.org/issues/8943