Backport #6104
closed
- Category set to core
- Assignee set to usa (Usaku NAKAMURA)
Patrick,
Actually as I described in #5297, the error is not File.join but the result of Dir.glob coming using the current Encoding.default_external and not the filesystem one:
V:\>chcp 1252
Active code page: 1252
V:\>ruby -e "puts Dir.glob('*').first.encoding"
Windows-1252
V:\>chcp 437
Active code page: 437
V:\>ruby -e "puts Dir.glob('*').first.encoding"
IBM437
While File.expand_path is more smart about that.
V:\>chcp 1252
Active code page: 1252
V:\>ruby -e "puts File.expand_path('.').encoding"
Windows-1252
V:\>chcp 437
Active code page: 437
V:\>ruby -e "puts File.expand_path('.').encoding"
Windows-1252
Disregard previous comment, the issue with Dir.glob is something different.
irb(main):001:0> a = "foo"
=> "foo"
irb(main):002:0> a.encoding
=> #
irb(main):003:0> File.join(a).encoding
=> #
And more:
irb(main):005:0> a = "a".encode(Encoding::UTF_8)
=> "a"
irb(main):006:0> b = "b".encode(Encoding::UTF_8)
=> "b"
irb(main):007:0> a.encoding
=> #
irb(main):008:0> b.encoding
=> #
irb(main):009:0> File.join(a, b).encoding
=> #
- Tracker changed from Bug to Backport
- Project changed from Ruby master to Backport193
- Category deleted (
core)
- Target version deleted (
1.9.3)
- Status changed from Open to Closed
- % Done changed from 0 to 100
This issue was solved with changeset r34865.
Patrick, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
merge revision(s) r33525: [Backport #6104]
* file.c (rb_file_join): honor input encodings than ASCII-8BIT.
[ruby-core:40338] [Bug #5483]
Also available in: Atom
PDF
Like0
Like0Like0Like0Like0Like0