Skip to content

Commit ef0e585

Browse files
committed
[Truffle] - String#upcase(!) should preserve the string encoding.
1 parent 86cab8d commit ef0e585

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,7 +1172,10 @@ public UpcaseNode(UpcaseNode prev) {
11721172
@Specialization
11731173
public RubyString upcase(RubyString string) {
11741174
notDesignedForCompilation();
1175-
return string.getContext().makeString(string.toString().toUpperCase());
1175+
ByteList byteListString = ByteList.create(string.toString().toUpperCase());
1176+
byteListString.setEncoding(string.getBytes().getEncoding());
1177+
1178+
return string.getContext().makeString(byteListString);
11761179
}
11771180

11781181
}
@@ -1191,8 +1194,10 @@ public UpcaseBangNode(UpcaseBangNode prev) {
11911194
@Specialization
11921195
public RubyString upcaseBang(RubyString string) {
11931196
notDesignedForCompilation();
1197+
ByteList byteListString = ByteList.create(string.toString().toUpperCase());
1198+
byteListString.setEncoding(string.getBytes().getEncoding());
11941199

1195-
string.set(ByteList.create(string.toString().toUpperCase()));
1200+
string.set(byteListString);
11961201
return string;
11971202
}
11981203
}

0 commit comments

Comments
 (0)