Mercurial > vim
comparison runtime/doc/eval.txt @ 23380:2351b40af967 v8.2.2233
patch 8.2.2233: cannot convert a byte index into a character index
Commit: https://github.com/vim/vim/commit/17793ef23aae0bc94539390ccfe5e63b0ad39ff2
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Dec 28 12:56:58 2020 +0100
patch 8.2.2233: cannot convert a byte index into a character index
Problem: Cannot convert a byte index into a character index.
Solution: Add charidx(). (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/7561)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 28 Dec 2020 13:00:07 +0100 |
parents | fab58304f77d |
children | 15fa3923cc49 |
comparison
equal
deleted
inserted
replaced
23379:200f510d1b72 | 23380:2351b40af967 |
---|---|
2473 ch_status({handle} [, {options}]) | 2473 ch_status({handle} [, {options}]) |
2474 String status of channel {handle} | 2474 String status of channel {handle} |
2475 changenr() Number current change number | 2475 changenr() Number current change number |
2476 char2nr({expr} [, {utf8}]) Number ASCII/UTF8 value of first char in {expr} | 2476 char2nr({expr} [, {utf8}]) Number ASCII/UTF8 value of first char in {expr} |
2477 charclass({string}) Number character class of {string} | 2477 charclass({string}) Number character class of {string} |
2478 charidx({string}, {idx} [, {countcc}]) | |
2479 Number char index of byte {idx} in {string} | |
2478 chdir({dir}) String change current working directory | 2480 chdir({dir}) String change current working directory |
2479 cindent({lnum}) Number C indent for line {lnum} | 2481 cindent({lnum}) Number C indent for line {lnum} |
2480 clearmatches([{win}]) none clear all matches | 2482 clearmatches([{win}]) none clear all matches |
2481 col({expr}) Number column nr of cursor or mark | 2483 col({expr}) Number column nr of cursor or mark |
2482 complete({startcol}, {matches}) none set Insert mode completion | 2484 complete({startcol}, {matches}) none set Insert mode completion |
3586 2 word character | 3588 2 word character |
3587 3 emoji | 3589 3 emoji |
3588 other specific Unicode class | 3590 other specific Unicode class |
3589 The class is used in patterns and word motions. | 3591 The class is used in patterns and word motions. |
3590 | 3592 |
3593 *charidx()* | |
3594 charidx({string}, {idx} [, {countcc}]) | |
3595 Return the character index of the byte at {idx} in {string}. | |
3596 The index of the first character is zero. | |
3597 If there are no multibyte characters the returned value is | |
3598 equal to {idx}. | |
3599 When {countcc} is omitted or zero, then composing characters | |
3600 are not counted separately, their byte length is added to the | |
3601 preceding base character. | |
3602 When {countcc} is set to 1, then composing characters are | |
3603 counted as separate characters. | |
3604 Returns -1 if the arguments are invalid or if {idx} is greater | |
3605 than the index of the last byte in {string}. An error is | |
3606 given if the first argument is not a string, the second | |
3607 argument is not a number or when the third argument is present | |
3608 and is not zero or one. | |
3609 See |byteidx()| and |byteidxcomp()| for getting the byte index | |
3610 from the character index. | |
3611 Examples: > | |
3612 echo charidx('áb́ć', 3) returns 1 | |
3613 echo charidx('áb́ć', 6, 1) returns 4 | |
3614 echo charidx('áb́ć', 16) returns -1 | |
3615 < | |
3616 Can also be used as a |method|: > | |
3617 GetName()->charidx(idx) | |
3591 | 3618 |
3592 chdir({dir}) *chdir()* | 3619 chdir({dir}) *chdir()* |
3593 Change the current working directory to {dir}. The scope of | 3620 Change the current working directory to {dir}. The scope of |
3594 the directory change depends on the directory of the current | 3621 the directory change depends on the directory of the current |
3595 window: | 3622 window: |