From: Luis Lavena Date: 2012-03-12T00:10:20+09:00 Subject: [ruby-core:43234] [ruby-trunk - Bug #5570] Encoding of environment variables on Windows Issue #5570 has been updated by Luis Lavena. Correct, A example that reproduces the issue:
C:\Users\Luis>ruby -v
ruby 1.9.3p155 (2012-03-03 revision 34878) [i386-mingw32]

C:\Users\Luis>chcp
Active code page: 1252

C:\Users\Luis>SET FOO=f������

C:\Users\Luis>ruby -e "puts ENV['FOO']"
f������

C:\Users\Luis>chcp 65001
Active code page: 65001

C:\Users\Luis>ruby -e "puts ENV['FOO']"
f���������
This also happens with environment variables used to construct users home directory "~" if they contain accented characters. ---------------------------------------- Bug #5570: Encoding of environment variables on Windows https://bugs.ruby-lang.org/issues/5570 Author: Nikolai Weibull Status: Assigned Priority: Normal Assignee: Usaku NAKAMURA Category: core Target version: ruby -v: ruby 1.9.3dev (2011-09-13 revision 33263) [i386-mingw32] It seems that the filesystem encoding is forced upon environment variables. There is, however, no guarantee that this encoding is the correct one. Getenv() probably shouldn���t be used on Windows at all. Using _wgetenv instead should guarantee that the returned result is encoded properly and it can then be converted to the filesystem encoding. -- http://bugs.ruby-lang.org/