From: Bruno Haible Date: Thu, 9 Jul 2020 15:28:48 +0000 (+0200) Subject: unicodeio: Fix wrong result on Solaris 11. X-Git-Tag: v1.0~3891 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=12c89745e39fb7b7dbdba732393dd0251202cadb;p=gnulib.git unicodeio: Fix wrong result on Solaris 11. Reported by Kiyoshi Kanazawa via Akim Demaille in . * lib/unicodeio.c (unicode_to_mb): Handle question mark fallback characters on Solaris. * tests/test-unicodeio.c (main): In the "C" locale, expect either the UTF-8 output or the specified fallback. --- diff --git a/ChangeLog b/ChangeLog index c2182f08c5..556fb53525 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2020-07-09 Bruno Haible + + unicodeio: Fix wrong result on Solaris 11. + Reported by Kiyoshi Kanazawa + via Akim Demaille in + . + * lib/unicodeio.c (unicode_to_mb): Handle question mark fallback + characters on Solaris. + * tests/test-unicodeio.c (main): In the "C" locale, expect either the + UTF-8 output or the specified fallback. + 2020-07-08 Bruno Haible unicodeio: Add tests. diff --git a/lib/unicodeio.c b/lib/unicodeio.c index 8ae3308671..81fe0ddbf9 100644 --- a/lib/unicodeio.c +++ b/lib/unicodeio.c @@ -133,6 +133,10 @@ unicode_to_mb (unsigned int code, /* Irix iconv() inserts a NUL byte if it cannot convert. */ # if !defined _LIBICONV_VERSION && (defined sgi || defined __sgi) || (res > 0 && code != 0 && outptr - outbuf == 1 && *outbuf == '\0') +# endif + /* Solaris 11 iconv() inserts a '?' if it cannot convert. */ +# if !defined _LIBICONV_VERSION && defined __sun + || (res > 0 && code != 0 && outptr - outbuf == 1 && *outbuf == '?') # endif ) return failure (code, NULL, callback_arg); diff --git a/tests/test-unicodeio.c b/tests/test-unicodeio.c index be91a91646..fa28e98e66 100644 --- a/tests/test-unicodeio.c +++ b/tests/test-unicodeio.c @@ -62,6 +62,7 @@ main (int argc, char *argv[]) if (argc > 1) switch (argv[1][0]) { + case '1': /* On some platforms, the "C" locale has UTF-8 encoding. */ case '2': ASSERT (strcmp (result, TEST_CODE_AS_UTF8) == 0); break;