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

String#codepoints for one-byte encodings #4533

Closed
InfraRuby opened this issue Mar 16, 2017 · 4 comments
Closed

String#codepoints for one-byte encodings #4533

InfraRuby opened this issue Mar 16, 2017 · 4 comments

Comments

@InfraRuby
Copy link

On many versions of JRuby, including 9.1.8.0:

"\x80".force_encoding("WINDOWS-1252").codepoints.first # => 0x80

I expected 0x20AC: https://en.wikipedia.org/wiki/Windows-1252

See:
https://github.com/jruby/jruby/blob/9.1.8.0/core/src/main/java/org/jruby/RubyString.java#L5117-L5118
https://github.com/jruby/jruby/blob/9.1.8.0/core/src/main/java/org/jruby/util/StringSupport.java#L1473

@headius
Copy link
Member

headius commented Mar 16, 2017

We behave like MRI does here, so I'd be reluctant to change it.

$ rvm ruby-2.4 do ruby -e 'p "\x80".force_encoding("WINDOWS-1252").codepoints.first.to_s(16)'
"80"

If you believe this is wrong, I think you should take it up with them on their bug tracker first.

@InfraRuby
Copy link
Author

If you believe this is wrong, I think you should take it up with them on their bug tracker first.

Ok: https://bugs.ruby-lang.org/issues/13321

@lopex
Copy link
Contributor

lopex commented Mar 16, 2017

I'ts an issue with codepoints method ifself or jcodings ?

@InfraRuby
Copy link
Author

@enebo enebo added this to the Invalid or Duplicate milestone May 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants