import { charidx } from "https://deno.land/x/denops_std@v4.2.0/function/mod.ts";
Return the character index of the byte at {idx} in {string}.
The index of the first character is zero.
If there are no multibyte characters the returned value is
equal to {idx}.
When {countcc} is omitted or FALSE
, then composing characters
are not counted separately, their byte length is
added to the preceding base character.
When {countcc} is TRUE
, then composing characters are
counted as separate characters.
Returns -1 if the arguments are invalid or if {idx} is greater
than the index of the last byte in {string}. An error is
given if the first argument is not a string, the second
argument is not a number or when the third argument is present
and is not zero or one.
See byteidx()
and byteidxcomp()
for getting the byte index
from the character index.
Examples:
echo charidx('áb́ć', 3) returns 1
echo charidx('áb́ć', 6, 1) returns 4
echo charidx('áb́ć', 16) returns -1
Can also be used as a method
:
GetName()->charidx(idx)