patch 9.1.1223: wrong translation used for encoding failures
Problem: wrong translation for encoding failures because of using
literal "from" and "to" in the resulting error message
(RestorerZ)
Solution: use separate error messages for errors "from" and "to"
encoding errors.
fixes: #16898
closes: #16918
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt
index bb6f917..b7791cc 100644
--- a/runtime/doc/builtin.txt
+++ b/runtime/doc/builtin.txt
@@ -1311,7 +1311,7 @@
encoding. The value is a |String|. See
|encoding-names| for the supported values
(plus the special value "none").
- *E1515*
+ *E1515* *E1516*
When current 'encoding' is "utf-8", an error is given and an
empty List is returned if an invalid byte sequence is
encountered in {blob}. To suppress this validation and get
diff --git a/runtime/doc/tags b/runtime/doc/tags
index c25effa..8f3fd50 100644
--- a/runtime/doc/tags
+++ b/runtime/doc/tags
@@ -4589,6 +4589,7 @@
E1513 message.txt /*E1513*
E1514 options.txt /*E1514*
E1515 builtin.txt /*E1515*
+E1516 builtin.txt /*E1516*
E152 helphelp.txt /*E152*
E153 helphelp.txt /*E153*
E154 helphelp.txt /*E154*
diff --git a/src/errors.h b/src/errors.h
index a116505..ca5ec85 100644
--- a/src/errors.h
+++ b/src/errors.h
@@ -3660,5 +3660,7 @@
INIT(= N_("E1513: Cannot switch buffer. 'winfixbuf' is enabled"));
EXTERN char e_invalid_return_type_from_findfunc[]
INIT(= N_("E1514: 'findfunc' did not return a List type"));
-EXTERN char e_str_encoding_failed[]
- INIT(= N_("E1515: Unable to convert %s '%s' encoding"));
+EXTERN char e_str_encoding_from_failed[]
+ INIT(= N_("E1515: Unable to convert from '%s' encoding"));
+EXTERN char e_str_encoding_to_failed[]
+ INIT(= N_("E1516: Unable to convert to '%s' encoding"));
diff --git a/src/strings.c b/src/strings.c
index 640ad39..d6f1b38 100644
--- a/src/strings.c
+++ b/src/strings.c
@@ -1339,7 +1339,7 @@
vim_free(str);
if (converted_str == NULL)
{
- semsg(_(e_str_encoding_failed), "from", from_encoding);
+ semsg(_(e_str_encoding_from_failed), from_encoding);
goto done;
}
}
@@ -1348,7 +1348,7 @@
{
if (!utf_valid_string(converted_str, NULL))
{
- semsg(_(e_str_encoding_failed), "from", p_enc);
+ semsg(_(e_str_encoding_from_failed), p_enc);
vim_free(converted_str);
goto done;
}
@@ -1414,7 +1414,7 @@
str = convert_string(str, p_enc, to_encoding);
if (str == NULL)
{
- semsg(_(e_str_encoding_failed), "to", to_encoding);
+ semsg(_(e_str_encoding_to_failed), to_encoding);
goto done;
}
}
diff --git a/src/testdir/test_functions.vim b/src/testdir/test_functions.vim
index 724fda0..c498ec0 100644
--- a/src/testdir/test_functions.vim
+++ b/src/testdir/test_functions.vim
@@ -4422,10 +4422,10 @@
call assert_fails("call str2blob(['abc'], [])", 'E1206: Dictionary required for argument 2')
call assert_fails("call str2blob(['abc'], {'encoding': []})", 'E730: Using a List as a String')
- call assert_fails("call str2blob(['abc'], {'encoding': 'ab12xy'})", 'E1515: Unable to convert to ''ab12xy'' encoding')
- call assert_fails("call str2blob(['ŝş'], {'encoding': 'latin1'})", 'E1515: Unable to convert to ''latin1'' encoding')
- call assert_fails("call str2blob(['அஇ'], {'encoding': 'latin1'})", 'E1515: Unable to convert to ''latin1'' encoding')
- call assert_fails("call str2blob(['🁰🁳'], {'encoding': 'latin1'})", 'E1515: Unable to convert to ''latin1'' encoding')
+ call assert_fails("call str2blob(['abc'], {'encoding': 'ab12xy'})", 'E1516: Unable to convert to ''ab12xy'' encoding')
+ call assert_fails("call str2blob(['ŝş'], {'encoding': 'latin1'})", 'E1516: Unable to convert to ''latin1'' encoding')
+ call assert_fails("call str2blob(['அஇ'], {'encoding': 'latin1'})", 'E1516: Unable to convert to ''latin1'' encoding')
+ call assert_fails("call str2blob(['🁰🁳'], {'encoding': 'latin1'})", 'E1516: Unable to convert to ''latin1'' encoding')
END
call v9.CheckLegacyAndVim9Success(lines)
endfunc
diff --git a/src/version.c b/src/version.c
index ee5b5ed..b4f6312 100644
--- a/src/version.c
+++ b/src/version.c
@@ -705,6 +705,8 @@
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1223,
+/**/
1222,
/**/
1221,