Skip to content

Commit

Permalink
Fix chars and length string functions to account for multibyte charac…
Browse files Browse the repository at this point in the history
…ters
  • Loading branch information
stirante committed Jul 12, 2023
1 parent 53a8598 commit 4f95338
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions jsonte/functions/string_functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -713,15 +713,15 @@ func regexReplace(str, pattern, repl types.JsonString) (types.JsonString, error)
}

func chars(str types.JsonString) types.JsonArray {
arr := make([]types.JsonType, len(str.StringValue()))
arr := make([]types.JsonType, len([]rune(str.StringValue())))
for i, c := range str.StringValue() {
arr[i] = types.NewString(string(c))
}
return types.JsonArray{Value: arr}
}

func length(str types.JsonString) types.JsonNumber {
return types.AsNumber(len(str.StringValue()))
return types.AsNumber(len([]rune(str.StringValue())))
}

func trim(str types.JsonString) types.JsonString {
Expand Down

0 comments on commit 4f95338

Please sign in to comment.