diff options
author | Eduardo Chappa <chappa@washington.edu> | 2021-04-18 09:54:53 -0600 |
---|---|---|
committer | Eduardo Chappa <chappa@washington.edu> | 2021-04-18 09:54:53 -0600 |
commit | 43f4dca2ead9fb8f65778c2772228dff554e1c75 (patch) | |
tree | c70773789fcac9fb86baf4451a57ec75548a75cb /pith/charconv/utf8.c | |
parent | 2807fa1f8a4125bc4fd1992f3e2d6c0a12005c62 (diff) | |
download | alpine-43f4dca2ead9fb8f65778c2772228dff554e1c75.tar.xz |
* Addition of testing for wctomb(), which will be used in systems that
do not have wcrtomb(). Work in collaboration with professor Martin
Trusler.
Diffstat (limited to 'pith/charconv/utf8.c')
-rw-r--r-- | pith/charconv/utf8.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/pith/charconv/utf8.c b/pith/charconv/utf8.c index 1651252e..42a364b3 100644 --- a/pith/charconv/utf8.c +++ b/pith/charconv/utf8.c @@ -125,6 +125,7 @@ pith_ucs4width(UCS ucs) int wtomb(char *dest, UCS ucs) { + int rv; /* * We believe that on modern unix systems wchar_t is a UCS-4 character. * That's the assumption here. @@ -150,7 +151,14 @@ wtomb(char *dest, UCS ucs) return(ret); } else - return(wcrtomb(dest, (wchar_t) ucs, NULL)); +#if defined(HAVE_WCRTOMB) + rv = wcrtomb(dest, (wchar_t) ucs, NULL); +#elif defined(HAVE_WCTOMB) + rv = wctomb(dest, (wchar_t) ucs); +#else + rv = -1; +#endif + return rv; } |