Project

General

Profile

Actions

Bug #10493

closed

Wrong encoding for Etc.getlogin in Windows

Added by davispuh (Dāvis Mosāns) about 10 years ago. Updated almost 10 years ago.

Status:
Closed
Assignee:
-
Target version:
ruby -v:
ruby 2.1.4p265 (2014-10-27 revision 48166) [x64-mingw32]
[ruby-core:66163]

Description

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.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0