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

Exception inspect in wrong encoding #5923

Closed
jlahtinen opened this issue Oct 18, 2019 · 1 comment
Closed

Exception inspect in wrong encoding #5923

jlahtinen opened this issue Oct 18, 2019 · 1 comment
Milestone

Comments

@jlahtinen
Copy link
Contributor

@jlahtinen jlahtinen commented Oct 18, 2019

Environment

Seems to be problem since 1.7.27 (probably earlier also).
My console encoding:

$ echo $LANG
en_GB.utf8

Expected Behavior

cruby gives excepted output for inspect:

$ ruby -e 'e = Exception.new "å"; puts "#{RUBY_PLATFORM} - #{RUBY_VERSION} - #{e} - #{e.inspect}"'
x86_64-linux - 2.5.3 - å - #<Exception: å>

Actual Behavior

jruby behaviour:

$ ruby -e 'e = Exception.new "å"; puts "#{RUBY_PLATFORM} - #{RUBY_VERSION} - #{e} - #{e.inspect}"'
java - 2.5.3 - å - #<Exception: Ã¥>

Seems like "å" is read inside exception as ISO-8859-1 and ouputted as encoded "UTF-8"

$ ruby -e 'puts "å".force_encoding("ISO-8859-1").encode("UTF-8")'
Ã¥
@enebo enebo added this to the JRuby 9.2.9.0 milestone Oct 18, 2019
@enebo

This comment has been minimized.

Copy link
Member

@enebo enebo commented Oct 18, 2019

Note: Our inspect code internally is building a String up using a StringBuilder and not our newer str() methods (which assumes all string data will end up being in Java's default charset). We just need to change this code to use our newer APIs.

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

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.