The current length() function for strings counts bytes rather than Unicode codepoints, which makes it difficult to work with non-ASCII text. For example:
Add a new function like strlen() or enhance the existing length() to handle Unicode properly by using utf8.RuneCountInString() from the standard library when operating on string values.
The current
length()
function for strings counts bytes rather than Unicode codepoints, which makes it difficult to work with non-ASCII text. For example:Suggested Implementation
Add a new function like
strlen()
or enhance the existinglength()
to handle Unicode properly by usingutf8.RuneCountInString()
from the standard library when operating on string values.Example implementation approach:
This would make the library more useful for international text processing and JSONPath queries involving non-ASCII strings.
Benefits
Let me know if you would like me to provide additional examples or test cases.
Related Go documentation: https://pkg.go.dev/unicode/utf8#RuneCountInString