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

Hash#inspect differs from MRI Ruby 2.2.1; This problem occurs if Hash has double-quoted UTF8 symbol key. #2713

Closed
k77ch7 opened this issue Mar 17, 2015 · 2 comments · Fixed by #2899

Comments

@k77ch7
Copy link
Contributor

k77ch7 commented Mar 17, 2015

The following test.rb differs from MRI Ruby 2.2.1 on JRuby master.

test.rb

# encoding: utf-8
h = { "Ãa1": true }
p h

MRI Ruby 2.2.1

$ ruby ~/development/test.rb
{:Ãa1=>true}

JRuby master

$ jruby ~/development/test.rb
{:"Ãa1"=>true}

My env

jruby 9.0.0.0-SNAPSHOT (2.2.1) 2015-03-17 c9a5cca Java HotSpot(TM) 64-Bit Server VM 25.5-b02 on 1.8.0_05-b13 +jit [darwin-x86_64]
@enebo
Copy link
Member

enebo commented Mar 18, 2015

We (you) can fix this but I find MRI's output to be strange. You would think their output on inspect would be valid Ruby syntax? Makes me wonder if this is our bug or theirs?

@k77ch7
Copy link
Contributor Author

k77ch7 commented Mar 25, 2015

I thought wrong. I think that this cause is Symbol#inspect rather than Hash#inspect.
The following symbol_test.rb differs from MRI Ruby. The different result occurs in the case of UTF8 string symbol.

symbol_test.rb

# encoding: utf-8

p :"Ãa1".inspect
p :"a1".inspect
p :"1".inspect

MRI Ruby 1.9.3, 2.0.0, 2.1.4 and 2.2,1

$ ruby ~/development/symbol_test.rb
":Ãa1"
":a1"
":\"1\""

JRuby master and 1.7.19

$ jruby ~/development/symbol_test.rb
":\"Ãa1\""
":a1"
":\"1\""

@k77ch7 k77ch7 changed the title Hash#inspect differs from MRI Ruby 2.2.0; This problem occurs if Hash has double-quoted UTF8 key. Hash#inspect differs from MRI Ruby 2.2.1; This problem occurs if Hash has double-quoted UTF8 key. Mar 27, 2015
@k77ch7 k77ch7 changed the title Hash#inspect differs from MRI Ruby 2.2.1; This problem occurs if Hash has double-quoted UTF8 key. Hash#inspect differs from MRI Ruby 2.2.1; This problem occurs if Hash has double-quoted UTF8 symbol key. Apr 21, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants