Project

General

Profile

Actions

Bug #17517

closed

File.expand_path returns us-ascii when both arguments are ascii compat

Added by znz (Kazuhiro NISHIYAMA) almost 4 years ago. Updated almost 4 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:101954]

Description

Is this intentional?

p __dir__.encoding  #=> #<Encoding:UTF-8>
p 'hoge'.encoding   #=> #<Encoding:UTF-8>
p File.expand_path('hoge', __dir__).encoding #=> #<Encoding:US-ASCII>
% docker run -it --rm ghcr.io/ruby/all-ruby env ALL_RUBY_SINCE=ruby-1.9 ./all-ruby -e 'p File.expand_path("hoge".encode("utf-8"), "/".encode("utf-8")).encoding'
ruby-1.9.0-0        -e:1:in `encode': transcoding not supported (from ASCII-8BIT to UTF-8) (ArgumentError)
                    	from -e:1:in `<main>'
                exit 1
ruby-1.9.0-1        #<Encoding:ASCII-8BIT>
ruby-1.9.0-2        #<Encoding:US-ASCII>
...
ruby-1.9.1-p129     #<Encoding:US-ASCII>
ruby-1.9.1-p243     #<Encoding:UTF-8>
...
ruby-1.9.2-preview1 #<Encoding:UTF-8>
ruby-1.9.2-preview3 #<Encoding:US-ASCII>
...
ruby-3.0.0          #<Encoding:US-ASCII>
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0