You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
String#b is supposed to make a copy of a string and set its encoding to ASCII-8BIT. As an optimization, JRuby uses a cheap dup operation that causes the new string to share the original's backing store. The problem is any changes made to the new string's encoding are shared with the source string.
Example:
$ ruby -v
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux]
$ ruby -e "s = 'x'; p s.encoding.name; p s.b.encoding.name; p s.encoding.name"
"UTF-8"
"ASCII-8BIT"
"UTF-8"
$ JRUBY_OPTS="" bin/jruby -v
jruby 9.0.0.0-SNAPSHOT (2.2.0p0) 2014-12-18 766148d Java HotSpot(TM) 64-Bit Server VM 24.72-b04 on 1.7.0_72-b14 +jit [linux-amd64]
$ JRUBY_OPTS="" bin/jruby -e "s = 'x'; p s.encoding.name; p s.b.encoding.name; p s.encoding.name"
"UTF-8"
"ASCII-8BIT"
"ASCII-8BIT"
Doing a full dupe should be sufficient to fix the problem.
The text was updated successfully, but these errors were encountered:
String#b
is supposed to make a copy of a string and set its encoding to ASCII-8BIT. As an optimization, JRuby uses a cheapdup
operation that causes the new string to share the original's backing store. The problem is any changes made to the new string's encoding are shared with the source string.Example:
Doing a full dupe should be sufficient to fix the problem.
The text was updated successfully, but these errors were encountered: