diff options
author | Charles Oliver Nutter <headius@headius.com> | 2023-01-18 23:14:37 -0600 |
---|---|---|
committer | Charles Oliver Nutter <headius@headius.com> | 2023-01-18 23:14:37 -0600 |
commit | c662354eecbae162b9287b8b566b432421414f96 (patch) | |
tree | 0944722c554a8cd34f55ff17ba6817055f6327bd /ext | |
parent | b8a09c1cdf192061dbf6e256d91941ecf9e0ac99 (diff) | |
download | psych-c662354eecbae162b9287b8b566b432421414f96.tar.gz |
Shorter path to encode strings in emitter
Diffstat (limited to 'ext')
-rw-r--r-- | ext/java/org/jruby/ext/psych/PsychEmitter.java | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/ext/java/org/jruby/ext/psych/PsychEmitter.java b/ext/java/org/jruby/ext/psych/PsychEmitter.java index 9180dcc..baaca4a 100644 --- a/ext/java/org/jruby/ext/psych/PsychEmitter.java +++ b/ext/java/org/jruby/ext/psych/PsychEmitter.java @@ -33,12 +33,14 @@ import org.jruby.Ruby; import org.jruby.RubyArray; import org.jruby.RubyBoolean; import org.jruby.RubyClass; +import org.jruby.RubyEncoding; import org.jruby.RubyModule; import org.jruby.RubyObject; import org.jruby.RubyString; import org.jruby.anno.JRubyMethod; import org.jruby.runtime.ThreadContext; import org.jruby.runtime.builtin.IRubyObject; +import org.jruby.util.ByteList; import org.jruby.util.IOOutputStream; import org.jruby.util.TypeConverter; import org.jruby.util.io.EncodingUtils; @@ -375,8 +377,9 @@ public class PsychEmitter extends RubyObject { TypeConverter.checkType(context, tag, stringClass); tagStr = (RubyString) tag; + ByteList bytes = tagStr.getByteList(); - return EncodingUtils.strConvEnc(context, tagStr, tagStr.getEncoding(), UTF8Encoding.INSTANCE).asJavaString(); + return RubyEncoding.decodeUTF8(bytes.unsafeBytes(), bytes.begin(), bytes.realSize()); } Emitter emitter; |