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

Comments

Projects
None yet
3 participants
@jordansissel
Copy link
Contributor

jordansissel commented Dec 2, 2014

  • 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

This comment has been minimized.

Copy link
Contributor Author

jordansissel commented Dec 2, 2014

Originally reported in Logstash: elastic/logstash#2155

@headius

This comment has been minimized.

Copy link
Member

headius commented Dec 10, 2014

A bug indeed.

headius added a commit that referenced this issue Dec 10, 2014

@headius headius closed this Dec 10, 2014

@headius headius added the core label Dec 10, 2014

@headius headius self-assigned this Dec 10, 2014

@jordansissel

This comment has been minimized.

Copy link
Contributor Author

jordansissel commented Dec 10, 2014

Thanks so much! <3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.