djberg96/win32-dir — pull request #3 by joshcooper (2013-07-11 05:50:20+00:00)
Title: Encode CSIDL strings as ascii_compatible

Ruby does not allow `File.join` to be called with non-ascii_compatible
encoded strings, like `UTF-16LE`[1]. As a result, if any of the CSIDL
constants, e.g. COMMON_APPDATA, are used in `File.join` it fails with:

irb(main):001:0> require 'win32/dir'
irb(main):002:0> File.join(Dir::COMMON_APPDATA, 'foo')
ArgumentError: string contains null byte

The ffi branch calls the wide versions of `SHGetFolderPathW`, and appears
to always have this issue. The master branch calls the ANSI versions, which
only exhibit the problem when using a non-ASCII locale, e.g. Italian
(locale 0410).

This commit ensures all CSIDL constants are encoded using the default
external encoding, similar to what is done for `Dir::getwd`.

Note I suspect the junction code has the same problem, e.g. `read_junction`.

[1] https://bugs.ruby-lang.org/issues/7168