Skip to content

Commit d7add91

Browse files
committed
STRBYTES() would error out if a null encoding was provided.
1 parent 9008e17 commit d7add91

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

docs/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ RookScript (C) Black Rook Software
33
by Matt Tropiano et al. (see AUTHORS.txt)
44

55

6+
Changed in 1.16.1
7+
-----------------
8+
9+
- `Fixed` STRBYTES() would error out if a null encoding was provided.
10+
11+
612
Changed in 1.16.0
713
-----------------
814

src/main/java/com/blackrook/rookscript/functions/common/StringFunctions.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ protected Usage usage()
603603
"Returns a buffer of bytes that represents the provided string in the specified encoding."
604604
)
605605
.parameter("string",
606-
type(Type.STRING, "The string to encode as bytes.")
606+
type(Type.STRING, "The string (or value converted to string) to encode as bytes.")
607607
)
608608
.parameter("encoding",
609609
type(Type.NULL, "Use native encoding."),
@@ -623,7 +623,7 @@ public boolean execute(ScriptInstance scriptInstance, ScriptValue returnValue)
623623
try
624624
{
625625
scriptInstance.popStackValue(temp);
626-
String encodingName = temp.asString();
626+
String encodingName = temp.isNull() ? null : temp.asString();
627627
scriptInstance.popStackValue(temp);
628628
String str = temp.asString();
629629

0 commit comments

Comments
 (0)