Project

General

Profile

Actions

Bug #19243

closed

Windows: Dir.home returns string in wrong encoding

Added by larskanis (Lars Kanis) over 1 year ago. Updated about 1 year ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 3.1.3p185 (2022-11-24 revision 1a6b16756e) [x64-mingw-ucrt]
[ruby-core:111333]

Description

Create a new local user on Windows called "kanisä".
Then login to the new user and run in cmd:

C:\Users\kanisä>ruby -e "p Dir.home"
"C:/Users/kanis\xE4"

C:\Users\kanisä>ruby -e "p Dir.home.encoding"
#<Encoding:UTF-8>

C:\Users\kanisä>ruby -e "p Dir.home.encode('utf-8', 'iso-8859-15')"
"C:/Users/kanisä"

C:\Users\kanisä>echo %USERPROFILE%
C:\Users\kanisä

Dir.home should encode the path in UTF-8. Instead the string is labeled as UTF-8 but bytes are encoded in iso-8859-15.

All versions between ruby-3.0 and current master branch are affected.

Updated by larskanis (Lars Kanis) over 1 year ago

This is fixed by commit https://github.com/ruby/ruby/commit/d6ce4180a5b4dacbac895c9911031a6df6c61136 in ruby-3.2.0. It should be backported to 3.1 and 3.0.

Actions #3

Updated by hsbt (Hiroshi SHIBATA) over 1 year ago

  • Status changed from Open to Closed
  • Backport changed from 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN to 2.7: UNKNOWN, 3.0: REQUIRED, 3.1: REQUIRED

Updated by nagachika (Tomoyuki Chikanaga) about 1 year ago

  • Backport changed from 2.7: UNKNOWN, 3.0: REQUIRED, 3.1: REQUIRED to 2.7: UNKNOWN, 3.0: REQUIRED, 3.1: DONE

ruby_3_1 823835499539aa53128a025ab72eb00c288dfb09 merged revision(s) d6ce4180a5b4dacbac895c9911031a6df6c61136.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0