Saturday, June 3, 2023

Re: [vim 9 script] String indexing behavior different from legacy Vim

On 2023-06-03, Lifepillar <lifepillar@lifepillar.me> wrote:
> Legacy Vim script:
>
> let text = 'àbc'
> echo text[2]
>
> Result: 'b'
>
> Vim 9 script:
>
> const text = 'àbc'
> echo text[2]
>
> Result: 'c'
>
> Is the different behavior (counting chars vs bytes?) intentional?

Mmh, even strpart(), which is supposed to count bytes, gives the same
result:

echo strpart(text, 2, 1)

is 'b' in legacy Vim, but 'c' in Vim 9 script.

Life.

--
--
You received this message from the "vim_use" 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_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/u5f4fs%24q6q%241%40ciao.gmane.io.

No comments: