forked from aniani/vim
updated for version 7.3.780
Problem: char2nr() and nr2char() always use 'encoding'. Solution: Add argument to use utf-8 characters. (Yasuhiro Matsumoto)
This commit is contained in:
parent
55b7b7eeb5
commit
d35d784e91
@ -1716,7 +1716,7 @@ call( {func}, {arglist} [, {dict}])
|
|||||||
any call {func} with arguments {arglist}
|
any call {func} with arguments {arglist}
|
||||||
ceil( {expr}) Float round {expr} up
|
ceil( {expr}) Float round {expr} up
|
||||||
changenr() Number current change number
|
changenr() Number current change number
|
||||||
char2nr( {expr}) Number ASCII value of first char in {expr}
|
char2nr( {expr}[, {utf8}]) Number ASCII/UTF8 value of first char in {expr}
|
||||||
cindent( {lnum}) Number C indent for line {lnum}
|
cindent( {lnum}) Number C indent for line {lnum}
|
||||||
clearmatches() none clear all matches
|
clearmatches() none clear all matches
|
||||||
col( {expr}) Number column nr of cursor or mark
|
col( {expr}) Number column nr of cursor or mark
|
||||||
@ -1873,7 +1873,7 @@ mkdir( {name} [, {path} [, {prot}]])
|
|||||||
mode( [expr]) String current editing mode
|
mode( [expr]) String current editing mode
|
||||||
mzeval( {expr}) any evaluate |MzScheme| expression
|
mzeval( {expr}) any evaluate |MzScheme| expression
|
||||||
nextnonblank( {lnum}) Number line nr of non-blank line >= {lnum}
|
nextnonblank( {lnum}) Number line nr of non-blank line >= {lnum}
|
||||||
nr2char( {expr}) String single char with ASCII value {expr}
|
nr2char( {expr}[, {utf8}]) String single char with ASCII/UTF8 value {expr}
|
||||||
or( {expr}, {expr}) Number bitwise OR
|
or( {expr}, {expr}) Number bitwise OR
|
||||||
pathshorten( {expr}) String shorten directory names in a path
|
pathshorten( {expr}) String shorten directory names in a path
|
||||||
pow( {x}, {y}) Float {x} to the power of {y}
|
pow( {x}, {y}) Float {x} to the power of {y}
|
||||||
@ -2294,14 +2294,16 @@ changenr() *changenr()*
|
|||||||
redo it is the number of the redone change. After undo it is
|
redo it is the number of the redone change. After undo it is
|
||||||
one less than the number of the undone change.
|
one less than the number of the undone change.
|
||||||
|
|
||||||
char2nr({expr}) *char2nr()*
|
char2nr({expr}[, {utf8}]) *char2nr()*
|
||||||
Return number value of the first char in {expr}. Examples: >
|
Return number value of the first char in {expr}. Examples: >
|
||||||
char2nr(" ") returns 32
|
char2nr(" ") returns 32
|
||||||
char2nr("ABC") returns 65
|
char2nr("ABC") returns 65
|
||||||
< The current 'encoding' is used. Example for "utf-8": >
|
< When {utf8} is omitted or zero, the current 'encoding' is used.
|
||||||
|
Example for "utf-8": >
|
||||||
char2nr("á") returns 225
|
char2nr("á") returns 225
|
||||||
char2nr("á"[0]) returns 195
|
char2nr("á"[0]) returns 195
|
||||||
< A combining character is a separate character.
|
< With {utf8} set to 1, always treat as utf-8 characters.
|
||||||
|
A combining character is a separate character.
|
||||||
|nr2char()| does the opposite.
|
|nr2char()| does the opposite.
|
||||||
|
|
||||||
cindent({lnum}) *cindent()*
|
cindent({lnum}) *cindent()*
|
||||||
@ -4371,14 +4373,16 @@ nextnonblank({lnum}) *nextnonblank()*
|
|||||||
below it, zero is returned.
|
below it, zero is returned.
|
||||||
See also |prevnonblank()|.
|
See also |prevnonblank()|.
|
||||||
|
|
||||||
nr2char({expr}) *nr2char()*
|
nr2char({expr}[, {utf8}]) *nr2char()*
|
||||||
Return a string with a single character, which has the number
|
Return a string with a single character, which has the number
|
||||||
value {expr}. Examples: >
|
value {expr}. Examples: >
|
||||||
nr2char(64) returns "@"
|
nr2char(64) returns "@"
|
||||||
nr2char(32) returns " "
|
nr2char(32) returns " "
|
||||||
< The current 'encoding' is used. Example for "utf-8": >
|
< When {utf8} is omitted or zero, the current 'encoding' is used.
|
||||||
|
Example for "utf-8": >
|
||||||
nr2char(300) returns I with bow character
|
nr2char(300) returns I with bow character
|
||||||
< Note that a NUL character in the file is specified with
|
< With {utf8} set to 1, always return utf-8 characters.
|
||||||
|
Note that a NUL character in the file is specified with
|
||||||
nr2char(10), because NULs are represented with newline
|
nr2char(10), because NULs are represented with newline
|
||||||
characters. nr2char(0) is a real NUL and terminates the
|
characters. nr2char(0) is a real NUL and terminates the
|
||||||
string, thus results in an empty string.
|
string, thus results in an empty string.
|
||||||
|
23
src/eval.c
23
src/eval.c
@ -7854,7 +7854,7 @@ static struct fst
|
|||||||
{"ceil", 1, 1, f_ceil},
|
{"ceil", 1, 1, f_ceil},
|
||||||
#endif
|
#endif
|
||||||
{"changenr", 0, 0, f_changenr},
|
{"changenr", 0, 0, f_changenr},
|
||||||
{"char2nr", 1, 1, f_char2nr},
|
{"char2nr", 1, 2, f_char2nr},
|
||||||
{"cindent", 1, 1, f_cindent},
|
{"cindent", 1, 1, f_cindent},
|
||||||
{"clearmatches", 0, 0, f_clearmatches},
|
{"clearmatches", 0, 0, f_clearmatches},
|
||||||
{"col", 1, 1, f_col},
|
{"col", 1, 1, f_col},
|
||||||
@ -8003,7 +8003,7 @@ static struct fst
|
|||||||
{"mzeval", 1, 1, f_mzeval},
|
{"mzeval", 1, 1, f_mzeval},
|
||||||
#endif
|
#endif
|
||||||
{"nextnonblank", 1, 1, f_nextnonblank},
|
{"nextnonblank", 1, 1, f_nextnonblank},
|
||||||
{"nr2char", 1, 1, f_nr2char},
|
{"nr2char", 1, 2, f_nr2char},
|
||||||
{"or", 2, 2, f_or},
|
{"or", 2, 2, f_or},
|
||||||
{"pathshorten", 1, 1, f_pathshorten},
|
{"pathshorten", 1, 1, f_pathshorten},
|
||||||
#ifdef FEAT_FLOAT
|
#ifdef FEAT_FLOAT
|
||||||
@ -9303,7 +9303,17 @@ f_char2nr(argvars, rettv)
|
|||||||
{
|
{
|
||||||
#ifdef FEAT_MBYTE
|
#ifdef FEAT_MBYTE
|
||||||
if (has_mbyte)
|
if (has_mbyte)
|
||||||
|
{
|
||||||
|
int utf8 = 0;
|
||||||
|
|
||||||
|
if (argvars[1].v_type != VAR_UNKNOWN)
|
||||||
|
utf8 = get_tv_number_chk(&argvars[1], NULL);
|
||||||
|
|
||||||
|
if (utf8)
|
||||||
|
rettv->vval.v_number = (*utf_ptr2char)(get_tv_string(&argvars[0]));
|
||||||
|
else
|
||||||
rettv->vval.v_number = (*mb_ptr2char)(get_tv_string(&argvars[0]));
|
rettv->vval.v_number = (*mb_ptr2char)(get_tv_string(&argvars[0]));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
rettv->vval.v_number = get_tv_string(&argvars[0])[0];
|
rettv->vval.v_number = get_tv_string(&argvars[0])[0];
|
||||||
@ -14360,7 +14370,16 @@ f_nr2char(argvars, rettv)
|
|||||||
|
|
||||||
#ifdef FEAT_MBYTE
|
#ifdef FEAT_MBYTE
|
||||||
if (has_mbyte)
|
if (has_mbyte)
|
||||||
|
{
|
||||||
|
int utf8 = 0;
|
||||||
|
|
||||||
|
if (argvars[1].v_type != VAR_UNKNOWN)
|
||||||
|
utf8 = get_tv_number_chk(&argvars[1], NULL);
|
||||||
|
if (utf8)
|
||||||
|
buf[(*utf_char2bytes)((int)get_tv_number(&argvars[0]), buf)] = NUL;
|
||||||
|
else
|
||||||
buf[(*mb_char2bytes)((int)get_tv_number(&argvars[0]), buf)] = NUL;
|
buf[(*mb_char2bytes)((int)get_tv_number(&argvars[0]), buf)] = NUL;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
@ -725,6 +725,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
780,
|
||||||
/**/
|
/**/
|
||||||
779,
|
779,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user