Skip to content

Commit 4114b53

Browse files
committed
Re-get the string encoding after conversion
1 parent 4e5817d commit 4114b53

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

ext/java/org/jruby/ext/stringio/StringIO.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1696,13 +1696,14 @@ private long stringIOWrite(ThreadContext context, Ruby runtime, IRubyObject arg)
16961696
try {
16971697
final Encoding enc = getEncoding();
16981698
if (enc == null) return 0;
1699-
final Encoding encStr = str.getEncoding();
1699+
Encoding encStr = str.getEncoding();
17001700
if (enc != encStr && enc != ASCIIEncoding.INSTANCE && enc != USASCIIEncoding.INSTANCE) {
17011701
RubyString converted = EncodingUtils.strConvEnc(context, str, encStr, enc);
17021702
if (converted == str && encStr != ASCIIEncoding.INSTANCE && encStr != USASCIIEncoding.INSTANCE) { /* conversion failed */
17031703
rb_enc_check(context, enc, str);
17041704
}
17051705
str = converted;
1706+
encStr = str.getEncoding();
17061707
}
17071708
final ByteList strByteList = str.getByteList();
17081709
len = str.size();

0 commit comments

Comments
 (0)