Hi Bram,

On Fri, Apr 14, 2023 at 12:55 PM Bram Moolenaar <[email protected]> wrote:
>
>
> Yegappan wrote:
>
> > I have updated the PR to add the utf16idx() function and introduced an
> > optional UTF-16 flag to the byteidx() and byteidxcomp() functions.
>
> Hmm, then when converting an UTF-16 index to a character index one would
> need to use byteidx() plus charidx().  Not ideal.  See my other message
> for a charidx() variant that does this in one step.
>
> Would it be needed to convert an UTF-16 index into a byte index?
> Depends on what it is used for, some functions work with a byte index,
> others with a character index.  So either we have functions for both, or
> there need to be two function calls.  I can't say I have a clear
> preference for either.
>

I have updated the PR to support conversion from a byte or character index
in a string to a UTF-16 index and vice versa.

A summary of these functions is below:

byteidx()
byteidxcomp()
    Convert from character or UTF-16 index to a byte index.
charidx()
    Convert from a byte or UTF-16 index to a character index.
utf16idx()
    Convert from a byte or character index to a UTF-16 index.

Regards,
Yegappan

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/CAAW7x7kpbBRJMD382vfs149y1D9vNcuf9Ap3Kk%3D7Z4fyjH%2BKGg%40mail.gmail.com.

Raspunde prin e-mail lui