I need to get the highest possible UTF8 character for a prefix search.
I have a data set like this:
A
Ba
Bf
C
Now I can do a prefix search by specifying start and end values:
Start: B
End: B* where * should be the highest possible UTF8 character.
How can I get this programatically using Javascript?
Edit: Here is a better example:
I need to send this prefix to a JSON RPC API. So I can’t do the actual comparison in JS.
But if I wanted to mach both strings starting with B, I would send
Start: B
End: B?
where ? is the biggest possible UTF8 character.
If it was ASCII, I could do "B" + String.fromCharCode(255), but this is just for ASCII. My strings are in UTF8, in which case this wouldn’t match all possible strings starting with B.
If you want to make a range, you can use
\uffff.Will find everything that starts with
foo.