Skip to content

Commit

Permalink
[Truffle] - String#upcase(!) should preserve the string encoding.
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasallan committed Dec 22, 2014
1 parent 86cab8d commit ef0e585
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

}
Expand All @@ -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;
}
}
Expand Down

0 comments on commit ef0e585

Please sign in to comment.