Skip to content

Commit 15d32a0

Browse files
committed
[Truffle] Added the default internal encoding to the encoding map.
1 parent 7879048 commit 15d32a0

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

truffle/src/main/java/org/jruby/truffle/nodes/core/EncodingNodes.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -553,24 +553,38 @@ public Object encodingMap(VirtualFrame frame) {
553553
lookupTableWriteNode.call(frame, ret, "[]=", null, key, value);
554554
}
555555

556+
final Encoding defaultInternalEncoding = getContext().getRuntime().getDefaultInternalEncoding();
557+
final Object internalTuple = newTupleNode.call(
558+
frame,
559+
getContext().getCoreLibrary().getTupleClass(),
560+
"create",
561+
null,
562+
getContext().makeString("internal"),
563+
defaultInternalEncoding == null ? nil() : defaultInternalEncoding.getIndex()
564+
);
565+
566+
lookupTableWriteNode.call(frame, ret, "[]=", null, getContext().newSymbol("INTERNAL"), internalTuple);
567+
568+
final Encoding defaultExternalEncoding = getContext().getRuntime().getDefaultExternalEncoding();
556569
final Object externalTuple = newTupleNode.call(
557570
frame,
558571
getContext().getCoreLibrary().getTupleClass(),
559572
"create",
560573
null,
561574
getContext().makeString("external"),
562-
getContext().getRuntime().getDefaultExternalEncoding().getIndex()
575+
defaultExternalEncoding == null ? nil() : defaultExternalEncoding.getIndex()
563576
);
564577

565578
lookupTableWriteNode.call(frame, ret, "[]=", null, getContext().newSymbol("EXTERNAL"), externalTuple);
566579

580+
final Encoding localeEncoding = getContext().getRuntime().getEncodingService().getLocaleEncoding();
567581
final Object localeTuple = newTupleNode.call(
568582
frame,
569583
getContext().getCoreLibrary().getTupleClass(),
570584
"create",
571585
null,
572586
getContext().makeString("locale"),
573-
getContext().getRuntime().getEncodingService().getLocaleEncoding().getIndex()
587+
localeEncoding == null ? nil() : localeEncoding.getIndex()
574588
);
575589

576590
lookupTableWriteNode.call(frame, ret, "[]=", null, getContext().newSymbol("LOCALE"), localeTuple);

0 commit comments

Comments
 (0)