Closed
Description
- Under MRI File.basename("/foo/bar/hello world".force_encoding("Windows-31J").encoding.to_s reports "Windows-31J".
- Under JRuby 1.7.16.1, the same code reports "UTF-8"
Having the returned string be different encoding than the input string to File.basename seems like a bug.
Full reproduction:
% rvm 2.1.4,1.7.16.1 do ruby test.rb
# Ruby 2.1.4
Windows-31J
Windows-31J
# JRuby 1.7.16.1
Windows-31J
UTF-8
Code:
# encoding: Windows-31J
x = "/hello/world"
puts x.encoding
puts File.basename(x).encoding