Skip to content

Encoding problem with string format #1511

retoo opened this Issue Feb 18, 2014 · 3 comments

4 participants

retoo commented Feb 18, 2014

String#% (string formatting) converts to wrong encoding when a %s is supplied with an integer.

x = "%s ä"
puts x.encoding
puts (x % 2).encoding


retoo commented Feb 18, 2014


x = "%s ä"
puts (x % "" + 2.to_s).encoding
@lucasallan lucasallan added a commit that referenced this issue Feb 19, 2014
@lucasallan lucasallan Fixing encoding problem with string format.
Related to issue #1511
JRuby Team member
headius commented Feb 20, 2014

Just to confirm, the PR referenced was never merged, right?

JRuby Team member

No, I got a few specs failing when ran it on Travis.

@headius headius added a commit that closed this issue Feb 20, 2014
@headius headius Fix #1511 by choosing original encoding appropriately.
The new logic here chooses the original (format) string's encoding
when appending a US-ASCII string if the format string contains
non-ASCII characters or its encoding is not ASCII compatible.
@headius headius closed this in bbf8e8f Feb 20, 2014
@enebo enebo added this to the JRuby 1.7.11 milestone Feb 21, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.