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

UTF-8 string interpolation in US-ASCII string sometimes returns wrong US-ASCII string #1242

Closed
rsim opened this issue Nov 19, 2013 · 3 comments
Closed
Milestone

Comments

@rsim
Copy link

@rsim rsim commented Nov 19, 2013

Create file quoting.rb with content

def quote(value)
  "'#{value}'"
end

And quote_encoding.rb with content

# encoding: utf-8

require "yaml"
require "quoting"

s = YAML.dump(abc: "āčē")

puts s.encoding # => UTF-8
puts quote(s).encoding  # => US-ASCII
puts quote(s.force_encoding("UTF-8")).encoding # => UTF-8

When executing quote_encoding.rb then output is

UTF-8
US-ASCII
UTF-8

Second result also should be UTF-8.

In JRuby 1.7.4 the result is UTF-8 in all cases but in JRuby 1.7.5, 1.7.6 and 1.7.8 second result is US-ASCII.

@headius
Copy link
Member

@headius headius commented Nov 19, 2013

Confirmed on 1.7.8. Appears to work right on master.

@headius
Copy link
Member

@headius headius commented Nov 19, 2013

Also confirmed on jruby-1_7, both interpreted and compiled. Strange that master does not exhibit the problem.

This is very similar to #1204 as well.

@headius headius closed this in 61014cf Nov 21, 2013
@headius
Copy link
Member

@headius headius commented Nov 21, 2013

This is now fixed, but we need a test for it.

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

Successfully merging a pull request may close this issue.

None yet
2 participants