Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File.basename can return a string with a different encoding than the input #2259

Closed
jordansissel opened this issue Dec 2, 2014 · 3 comments
Assignees
Labels
Milestone

Comments

@jordansissel
Copy link
Contributor

  • 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
@jordansissel
Copy link
Contributor Author

Originally reported in Logstash: elastic/logstash#2155

@headius
Copy link
Member

headius commented Dec 10, 2014

A bug indeed.

@jordansissel
Copy link
Contributor Author

Thanks so much! <3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants