[ruby-core:66192] [ruby-trunk - Bug #10493] Wrong encoding for Etc.getlogin in Windows

From: duerst@...
Date: 2014-11-11 01:59:00 UTC
List: ruby-core #66192
Issue #10493 has been updated by Martin Dürst.


Dāvis Mosāns wrote:
> No, *Encoding.default_external* is based on current consoles encoding. And by default it is IBM775, but can be different for each opened console. Also it's not related to Encoding which is used by Windows ANSI API. Windows-1257 encoding is set in Control Panel for non-Unicode programs and will be used for all Windows ANSI functions.

Can you say which section of the control panel that is?

> Proper way is to always use Windows Unicode/Wide API and then it will be encoded with UTF-16.
> 
> Thanks for patch, I'll test it when it will be released.

It would be highly desirable to test it before it's released.

----------------------------------------
Bug #10493: Wrong encoding for Etc.getlogin in Windows
https://bugs.ruby-lang.org/issues/10493#change-49890

* 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/

In This Thread

Prev Next