Project

General

Profile

Actions

Bug #10126

closed

Dir.home encoding is incorrect on Windows

Added by davispuh (Dāvis Mosāns) over 9 years ago. Updated over 4 years ago.

Status:
Closed
Assignee:
Target version:
-
ruby -v:
2.0.0p481
[ruby-core:64310]

Description

Dir.home string itself is actually returned encoded in cp775 (no matter what consoles encoding is)
but encoding information is as windows default encoding.

For example, if my home directory is C:\Users\Dāvis and windows default encoding 1257 with cosnole's encoding as 1252

dir = Dir.home
=> "C:/Users/D\x83vis"
dir.encoding
=> #<Encoding:Windows-1257>
puts dir
=> C:/Users/D�vis
dir.force_encoding('cp775')
puts dir
=> C:/Users/Dāvis

As can see, x83 is ā character in 775 encoding.

Updated by davispuh (Dāvis Mosāns) over 9 years ago

Looks like this have been fixed in Ruby 2.1

Testing with ruby 2.1.4p265 (2014-10-27 revision 48166) [x64-mingw32]

dir = Dir.home
puts dir
=> C:/Users/Dāvis
puts dir.encoding
=> #<Encoding:Windows-1257>
Actions #2

Updated by jeremyevans0 (Jeremy Evans) over 4 years ago

  • Status changed from Open to Closed
Actions

Also available in: Atom PDF

Like0
Like0Like0