Skip to content
Permalink
Browse files
[Truffle] - String#upcase(!) should preserve the string encoding.
  • Loading branch information
lucasallan committed Dec 22, 2014
1 parent 86cab8d commit ef0e5854e213431642fc4ef7506921a2d851b6e3
Showing with 7 additions and 2 deletions.
  1. +7 −2 core/src/main/java/org/jruby/truffle/nodes/core/StringNodes.java
@@ -1172,7 +1172,10 @@ public UpcaseNode(UpcaseNode prev) {
@Specialization
public RubyString upcase(RubyString string) {
notDesignedForCompilation();
return string.getContext().makeString(string.toString().toUpperCase());
ByteList byteListString = ByteList.create(string.toString().toUpperCase());
byteListString.setEncoding(string.getBytes().getEncoding());

return string.getContext().makeString(byteListString);
}

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

string.set(ByteList.create(string.toString().toUpperCase()));
string.set(byteListString);
return string;
}
}

0 comments on commit ef0e585

Please sign in to comment.