summaryrefslogtreecommitdiff
path: root/ext/etc
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-11-10 08:24:36 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-11-10 08:24:36 (GMT)
commit6ccf3d68c21c2eabefe80f9ff1f7b5296a9ddfd2 (patch)
treed4067ab10ba5b3b857388b3e7f2dbb69e4d41c8f /ext/etc
parente899fb19e9a845108c264ecc0e0542d68ce97fe7 (diff)
win32.c: login name encoding
* ext/etc/etc.c (etc_getlogin): set login name encoding properly. [ruby-core:66163] [Bug #10493] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48360 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/etc')
-rw-r--r--ext/etc/etc.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/ext/etc/etc.c b/ext/etc/etc.c
index 694ef5e..4173d33 100644
--- a/ext/etc/etc.c
+++ b/ext/etc/etc.c
@@ -81,8 +81,15 @@ etc_getlogin(VALUE obj)
login = getenv("USER");
#endif
- if (login)
- return rb_tainted_str_new2(login);
+ if (login) {
+#ifdef _WIN32
+ rb_encoding *extenc = rb_utf8_encoding();
+#else
+ rb_encoding *extenc = rb_locale_encoding();
+#endif
+ return rb_external_str_new_with_enc(login, strlen(login), extenc);
+ }
+
return Qnil;
}