changeset 32162:fab3e312a0b4 stable

unicode2native.m: Restore support for one input parameter (bug #64331). * scripts/string/unicode2native.m: Restore support for calling form with one input parameter. Add BIST.
author Markus Mützel <markus.muetzel@gmx.de>
date Fri, 23 Jun 2023 16:19:46 +0200
parents efcfafb7ad16
children 3815dfaf27e3 e8497a0fb249
files scripts/strings/unicode2native.m
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/strings/unicode2native.m	Wed Jun 21 16:37:33 2023 -0400
+++ b/scripts/strings/unicode2native.m	Fri Jun 23 16:19:46 2023 +0200
@@ -59,7 +59,7 @@
     error ("unicode2native: UTF8_STR must be a character vector");
   endif
 
-  if (! (ischar (codepage) && isrow (codepage)))
+  if (nargin > 1 && ! (ischar (codepage) && isrow (codepage)))
     error ("unicode2native: CODEPAGE must be a string");
   endif
 
@@ -78,6 +78,8 @@
 %! assert (unicode2native (["ЄЅІ" "\0" "ЇЈЉЊ"], "ISO-8859-5"),
 %!         uint8 ([164:166 0 167:170]));
 %!assert <*60480> (unicode2native (''), uint8 ([]))
+%!testif HAVE_ICONV <*64331>
+%! assert (! isempty (unicode2native ("abc")));
 
 # short character arrays with invalid UTF-8
 %!testif HAVE_ICONV <*63930>
@@ -105,7 +107,7 @@
 %!error <UTF8_STR must be a character vector> unicode2native (['ab'; 'cd'])
 %!error <UTF8_STR must be a character vector> unicode2native ({1 2 3 4})
 %!error <CODEPAGE must be a string> unicode2native ('ЄЅІЇЈЉЊ', 123)
-%!error <CODEPAGE must be a string> unicode2native ('ЄЅІЇЈЉЊ', ['ISO-8859-1']')
+%!error <CODEPAGE must be a string> unicode2native ('ЄЅІЇЈЉЊ', ['ISO-8859-1'].')
 %!testif HAVE_ICONV
 %! fail ("unicode2native ('a', 'foo')",
 %!       "converting from UTF-8 to codepage 'foo'");