Skip to content
Permalink
Browse files
Revert "Fixed #2388: String#b improperly updates encoding of source s…
…tring."

This reverts commit 4e40732.
  • Loading branch information
nirvdrum committed Dec 24, 2014
1 parent a5f607a commit aec88447efc940fa8251c2606896472196487b09
Showing with 6 additions and 7 deletions.
  1. +6 −7 core/src/main/java/org/jruby/RubyString.java
@@ -5963,11 +5963,8 @@ public IRubyObject encode(ThreadContext context, IRubyObject toEncoding,

@JRubyMethod
public IRubyObject force_encoding(ThreadContext context, IRubyObject enc) {
return force_encoding(context, context.runtime.getEncodingService().getEncodingFromObject(enc));
}

private IRubyObject force_encoding(ThreadContext context, Encoding encoding) {
modify19();
Encoding encoding = context.runtime.getEncodingService().getEncodingFromObject(enc);
associateEncoding(encoding);
clearCodeRange();
return this;
@@ -5985,9 +5982,11 @@ public IRubyObject ascii_only_p(ThreadContext context) {

@JRubyMethod
public IRubyObject b(ThreadContext context) {
RubyString dup = strDup(context.runtime);

return dup.force_encoding(context, ASCIIEncoding.INSTANCE);
Encoding encoding = ASCIIEncoding.INSTANCE;
RubyString dup = (RubyString)dup();
dup.associateEncoding(encoding);
dup.clearCodeRange();
return dup;
}

// MRI: str_scrub arity 0

0 comments on commit aec8844

Please sign in to comment.