diff --git a/core/src/main/java/org/jruby/util/ByteList.java b/core/src/main/java/org/jruby/util/ByteList.java index 1765e26c60a..fa01583dd8c 100644 --- a/core/src/main/java/org/jruby/util/ByteList.java +++ b/core/src/main/java/org/jruby/util/ByteList.java @@ -1163,7 +1163,9 @@ public int hashCode() { public String toString() { String decoded = this.stringValue; if (decoded == null) { - this.stringValue = decoded = decode(bytes, begin, realSize, ISO_LATIN_1); + Charset charset = this.encoding.getCharset(); + if (charset == null) charset = ISO_LATIN_1; + this.stringValue = decoded = decode(bytes, begin, realSize, charset); } return decoded; }