comparison runtime/doc/eval.txt @ 16235:219c58b3879c v8.1.1122

patch 8.1.1122: char2nr() does not handle composing characters commit https://github.com/vim/vim/commit/9d40128afd7fcd038ff6532722b55b1a8c189ce8 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Apr 6 13:18:12 2019 +0200 patch 8.1.1122: char2nr() does not handle composing characters Problem: char2nr() does not handle composing characters. Solution: Add str2list() and list2str(). (Ozaki Kiichi, closes https://github.com/vim/vim/issues/4190)
author Bram Moolenaar <Bram@vim.org>
date Sat, 06 Apr 2019 13:30:04 +0200
parents 0761a4c111a7
children b471858040bc
comparison
equal deleted inserted replaced
16234:dbfd219fe9b3 16235:219c58b3879c
2440 libcall({lib}, {func}, {arg}) String call {func} in library {lib} with {arg} 2440 libcall({lib}, {func}, {arg}) String call {func} in library {lib} with {arg}
2441 libcallnr({lib}, {func}, {arg}) Number idem, but return a Number 2441 libcallnr({lib}, {func}, {arg}) Number idem, but return a Number
2442 line({expr}) Number line nr of cursor, last line or mark 2442 line({expr}) Number line nr of cursor, last line or mark
2443 line2byte({lnum}) Number byte count of line {lnum} 2443 line2byte({lnum}) Number byte count of line {lnum}
2444 lispindent({lnum}) Number Lisp indent for line {lnum} 2444 lispindent({lnum}) Number Lisp indent for line {lnum}
2445 list2str({list} [, {utf8}]) String turn numbers in {list} into a String
2445 localtime() Number current time 2446 localtime() Number current time
2446 log({expr}) Float natural logarithm (base e) of {expr} 2447 log({expr}) Float natural logarithm (base e) of {expr}
2447 log10({expr}) Float logarithm of Float {expr} to base 10 2448 log10({expr}) Float logarithm of Float {expr} to base 10
2448 luaeval({expr} [, {expr}]) any evaluate |Lua| expression 2449 luaeval({expr} [, {expr}]) any evaluate |Lua| expression
2449 map({expr1}, {expr2}) List/Dict change each item in {expr1} to {expr} 2450 map({expr1}, {expr2}) List/Dict change each item in {expr1} to {expr}
2607 List spelling suggestions 2608 List spelling suggestions
2608 split({expr} [, {pat} [, {keepempty}]]) 2609 split({expr} [, {pat} [, {keepempty}]])
2609 List make |List| from {pat} separated {expr} 2610 List make |List| from {pat} separated {expr}
2610 sqrt({expr}) Float square root of {expr} 2611 sqrt({expr}) Float square root of {expr}
2611 str2float({expr}) Float convert String to Float 2612 str2float({expr}) Float convert String to Float
2613 str2list({expr} [, {utf8}]) List convert each character of {expr} to
2614 ASCII/UTF8 value
2612 str2nr({expr} [, {base}]) Number convert String to Number 2615 str2nr({expr} [, {base}]) Number convert String to Number
2613 strchars({expr} [, {skipcc}]) Number character length of the String {expr} 2616 strchars({expr} [, {skipcc}]) Number character length of the String {expr}
2614 strcharpart({str}, {start} [, {len}]) 2617 strcharpart({str}, {start} [, {len}])
2615 String {len} characters of {str} at {start} 2618 String {len} characters of {str} at {start}
2616 strdisplaywidth({expr} [, {col}]) Number display length of the String {expr} 2619 strdisplaywidth({expr} [, {col}]) Number display length of the String {expr}
6191 The indent is counted in spaces, the value of 'tabstop' is 6194 The indent is counted in spaces, the value of 'tabstop' is
6192 relevant. {lnum} is used just like in |getline()|. 6195 relevant. {lnum} is used just like in |getline()|.
6193 When {lnum} is invalid or Vim was not compiled the 6196 When {lnum} is invalid or Vim was not compiled the
6194 |+lispindent| feature, -1 is returned. 6197 |+lispindent| feature, -1 is returned.
6195 6198
6199 list2str({list} [, {utf8}]) *list2str()*
6200 Convert each number in {list} to a character string can
6201 concatenate them all. Examples: >
6202 list2str([32]) returns " "
6203 list2str([65, 66, 67]) returns "ABC"
6204 < The same can be done (slowly) with: >
6205 join(map(list, {nr, val -> nr2char(val)}), '')
6206 < |str2list()| does the opposite.
6207
6208 When {utf8} is omitted or zero, the current 'encoding' is used.
6209 With {utf8} is 1, always return utf-8 characters.
6210 With utf-8 composing characters work as expected: >
6211 list2str([97, 769]) returns "á"
6212 <
6196 localtime() *localtime()* 6213 localtime() *localtime()*
6197 Return the current time, measured as seconds since 1st Jan 6214 Return the current time, measured as seconds since 1st Jan
6198 1970. See also |strftime()| and |getftime()|. 6215 1970. See also |strftime()| and |getftime()|.
6199 6216
6200 6217
8720 12.0. You can strip out thousands separators with 8737 12.0. You can strip out thousands separators with
8721 |substitute()|: > 8738 |substitute()|: >
8722 let f = str2float(substitute(text, ',', '', 'g')) 8739 let f = str2float(substitute(text, ',', '', 'g'))
8723 < {only available when compiled with the |+float| feature} 8740 < {only available when compiled with the |+float| feature}
8724 8741
8742 str2list({expr} [, {utf8}]) *str2list()*
8743 Return a list containing the number values which represent
8744 each character in String {expr}. Examples: >
8745 str2list(" ") returns [32]
8746 str2list("ABC") returns [65, 66, 67]
8747 < |list2str()| does the opposite.
8748
8749 When {utf8} is omitted or zero, the current 'encoding' is used.
8750 With {utf8} set to 1, always treat the String as utf-8
8751 characters. With utf-8 composing characters are handled
8752 properly: >
8753 str2list("á") returns [97, 769]
8725 8754
8726 str2nr({expr} [, {base}]) *str2nr()* 8755 str2nr({expr} [, {base}]) *str2nr()*
8727 Convert string {expr} to a number. 8756 Convert string {expr} to a number.
8728 {base} is the conversion base, it can be 2, 8, 10 or 16. 8757 {base} is the conversion base, it can be 2, 8, 10 or 16.
8729 When {base} is omitted base 10 is used. This also means that 8758 When {base} is omitted base 10 is used. This also means that