summaryrefslogtreecommitdiffstats
path: root/runtime
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-03-14 19:46:45 +0100
committerBram Moolenaar <Bram@vim.org>2021-03-14 19:46:45 +0100
commit02b4d9b18a03549b68e364e428392b7a62766c74 (patch)
treee017eaa4d4531b7bccb612679b50848c94d9e5b3 /runtime
parent70ce8a1561c5396e4c4381f76a005cbb97646f80 (diff)
patch 8.2.2607: strcharpart() cannot include composing charactersv8.2.2607
Problem: strcharpart() cannot include composing characters. Solution: Add the {skipcc} argument.
Diffstat (limited to 'runtime')
-rw-r--r--runtime/doc/eval.txt26
1 files changed, 16 insertions, 10 deletions
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index 3e5c6ee44b..723a7329b3 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -1187,7 +1187,8 @@ byte under the cursor: >
In Vim9 script:
If expr8 is a String this results in a String that contains the expr1'th
-single character from expr8. To use byte indexes use |strpart()|.
+single character (including any composing characters) from expr8. To use byte
+indexes use |strpart()|.
Index zero gives the first byte or character. Careful: text column numbers
start with one!
@@ -1217,8 +1218,9 @@ In legacy Vim script the indexes are byte indexes. This doesn't recognize
multibyte encodings, see |byteidx()| for computing the indexes. If expr8 is
a Number it is first converted to a String.
-In Vim9 script the indexes are character indexes. To use byte indexes use
-|strpart()|.
+In Vim9 script the indexes are character indexes and include composing
+characters. To use byte indexes use |strpart()|. To use character indexes
+without including composing characters use |strcharpart()|.
The item at index expr1b is included, it is inclusive. For an exclusive index
use the |slice()| function.
@@ -2924,7 +2926,7 @@ str2list({expr} [, {utf8}]) List convert each character of {expr} to
str2nr({expr} [, {base} [, {quoted}]])
Number convert String to Number
strcharlen({expr}) Number character length of the String {expr}
-strcharpart({str}, {start} [, {len}])
+strcharpart({str}, {start} [, {len} [, {skipcc}]])
String {len} characters of {str} at
character {start}
strchars({expr} [, {skipcc}]) Number character count of the String {expr}
@@ -9919,7 +9921,7 @@ slice({expr}, {start} [, {end}]) *slice()*
Similar to using a |slice| "expr[start : end]", but "end" is
used exclusive. And for a string the indexes are used as
character indexes instead of byte indexes, like in
- |vim9script|.
+ |vim9script|. Also, composing characters are not counted.
When {end} is omitted the slice continues to the last item.
When {end} is -1 the last item is omitted.
@@ -10290,12 +10292,16 @@ strcharlen({expr}) *strcharlen()*
GetText()->strcharlen()
-strcharpart({src}, {start} [, {len}]) *strcharpart()*
+strcharpart({src}, {start} [, {len} [, {skipcc}]]) *strcharpart()*
Like |strpart()| but using character index and length instead
- of byte index and length. Composing characters are counted
- separately.
+ of byte index and length.
+ When {skipcc} is omitted or zero, composing characters are
+ counted separately.
+ When {skipcc} set to 1, Composing characters are ignored,
+ similar to |slice()|.
When a character index is used where a character does not
- exist it is assumed to be one character. For example: >
+ exist it is omitted and counted as one character. For
+ example: >
strcharpart('abc', -1, 2)
< results in 'a'.
@@ -10309,7 +10315,7 @@ strchars({expr} [, {skipcc}]) *strchars()*
When {skipcc} is omitted or zero, composing characters are
counted separately.
When {skipcc} set to 1, Composing characters are ignored.
- |strcharlen()| does the same.
+ |strcharlen()| always does this.
Also see |strlen()|, |strdisplaywidth()| and |strwidth()|.