From: davispuh@... Date: 2014-11-11T16:27:08+00:00 Subject: [ruby-core:66210] [ruby-trunk - Bug #10493] Wrong encoding for Etc.getlogin in Windows Issue #10493 has been updated by D��vis Mos��ns. Thanks, that was surprisingly easy. Only trunk didn't build so I compiled from ruby_2_1 branch and cherry-picked r48360, r48364 Now I can confirm that patch works. ```ruby name = Etc.getlogin puts name.inspect # "D\u0101vis" puts name.encoding # UTF-8 ``` But looks like encoding for string outputting have been broken somewhere (I hope it's fixed in some commits not yet merged in this branch) ```ruby puts "\u0101" => �� # on released Ruby 2.1.4p265 => ��? # on 2.1.5p272, I just compiled from ruby_2_1 branch ``` It used to be that when outputting string it's encoded to `Encoding.default_external`, but that's not the case for this. ---------------------------------------- Bug #10493: Wrong encoding for Etc.getlogin in Windows https://bugs.ruby-lang.org/issues/10493#change-49905 * Author: D��vis Mos��ns * Status: Closed * Priority: Normal * Assignee: * Category: ext * Target version: current: 2.2.0 * ruby -v: ruby 2.1.4p265 (2014-10-27 revision 48166) [x64-mingw32] * Backport: 2.0.0: REQUIRED, 2.1: REQUIRED ---------------------------------------- ~~~ruby name = Etc.getlogin # I've Windows username "D��vis" puts name # D���vis puts name.inspect # "D\xE2vis" puts name.encoding # ASCII-8BIT name.force_encoding('Windows-1257') puts name # D��vis ~~~ As you can see \xE2 isn't "��" in ASCII, but it is for Windws-1257 encoding. -- https://bugs.ruby-lang.org/