Project

General

Profile

Actions

Backport #6104

closed

File.join always returns as ASCII-8BIT regardless of input encoding

Added by patrickb (Patrick Bennett) over 12 years ago. Updated over 12 years ago.

Status:
Closed
[ruby-core:43027]

Description

I can show lots of different variations, but the simplest proof is:
irb(main):001:0> File.join('foo'.encode('utf-8')).encoding
=> #Encoding:ASCII-8BIT


Related issues 1 (0 open1 closed)

Related to Ruby master - Bug #5483: Pathname doesn’t deal with encodings properlyClosed10/25/2011Actions

Updated by luislavena (Luis Lavena) over 12 years ago

  • 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

Updated by luislavena (Luis Lavena) over 12 years ago

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
=> #

Updated by phasis68 (Heesob Park) over 12 years ago

I think this issue was solved with changeset [ruby-core:40338] [Bug #5483]">r33525.

Actions #4

Updated by naruse (Yui NARUSE) over 12 years ago

  • Tracker changed from Bug to Backport
  • Project changed from Ruby master to Backport193
  • Category deleted (core)
  • Target version deleted (1.9.3)
Actions #5

Updated by naruse (Yui NARUSE) over 12 years ago

  • 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]
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0