summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2013-01-23 17:17:10 +0100
committerBram Moolenaar <Bram@vim.org>2013-01-23 17:17:10 +0100
commitd35d784e9106a9d398b444ed9557664bbcb6a65c (patch)
treef355a77e327600d011c042159609fa9fab9e2d03 /src
parent55b7b7eeb50d4fab541ba151e0f653eb6e3852b8 (diff)
downloadvim-git-d35d784e9106a9d398b444ed9557664bbcb6a65c.tar.gz
updated for version 7.3.780v7.3.780
Problem: char2nr() and nr2char() always use 'encoding'. Solution: Add argument to use utf-8 characters. (Yasuhiro Matsumoto)
Diffstat (limited to 'src')
-rw-r--r--src/eval.c27
-rw-r--r--src/version.c2
2 files changed, 25 insertions, 4 deletions
diff --git a/src/eval.c b/src/eval.c
index f645e9683..46a1963de 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -7854,7 +7854,7 @@ static struct fst
{"ceil", 1, 1, f_ceil},
#endif
{"changenr", 0, 0, f_changenr},
- {"char2nr", 1, 1, f_char2nr},
+ {"char2nr", 1, 2, f_char2nr},
{"cindent", 1, 1, f_cindent},
{"clearmatches", 0, 0, f_clearmatches},
{"col", 1, 1, f_col},
@@ -8003,7 +8003,7 @@ static struct fst
{"mzeval", 1, 1, f_mzeval},
#endif
{"nextnonblank", 1, 1, f_nextnonblank},
- {"nr2char", 1, 1, f_nr2char},
+ {"nr2char", 1, 2, f_nr2char},
{"or", 2, 2, f_or},
{"pathshorten", 1, 1, f_pathshorten},
#ifdef FEAT_FLOAT
@@ -9303,7 +9303,17 @@ f_char2nr(argvars, rettv)
{
#ifdef FEAT_MBYTE
if (has_mbyte)
- rettv->vval.v_number = (*mb_ptr2char)(get_tv_string(&argvars[0]));
+ {
+ 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]));
+ }
else
#endif
rettv->vval.v_number = get_tv_string(&argvars[0])[0];
@@ -14360,7 +14370,16 @@ f_nr2char(argvars, rettv)
#ifdef FEAT_MBYTE
if (has_mbyte)
- buf[(*mb_char2bytes)((int)get_tv_number(&argvars[0]), buf)] = NUL;
+ {
+ 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;
+ }
else
#endif
{
diff --git a/src/version.c b/src/version.c
index a8cfdc567..72b552ae5 100644
--- a/src/version.c
+++ b/src/version.c
@@ -726,6 +726,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 780,
+/**/
779,
/**/
778,