diff options
author | Florian Weimer <fweimer@redhat.com> | 2018-04-05 12:50:58 +0200 |
---|---|---|
committer | Florian Weimer <fweimer@redhat.com> | 2018-04-05 12:50:58 +0200 |
commit | 0f339252697e6dcfc9e00be6cd8272d4260b90d2 (patch) | |
tree | 144326a4f739b40245b99d80d7f33436e8bbc74c /manual/charset.texi | |
parent | 08e92e2443a6ca4cfd45b87e22bef3454f369752 (diff) | |
download | glibc-0f339252697e6dcfc9e00be6cd8272d4260b90d2.zip glibc-0f339252697e6dcfc9e00be6cd8272d4260b90d2.tar.gz glibc-0f339252697e6dcfc9e00be6cd8272d4260b90d2.tar.bz2 |
manual: Move mbstouwcs to an example C file
Diffstat (limited to 'manual/charset.texi')
-rw-r--r-- | manual/charset.texi | 23 |
1 files changed, 1 insertions, 22 deletions
diff --git a/manual/charset.texi b/manual/charset.texi index 1867ace..6831ebe 100644 --- a/manual/charset.texi +++ b/manual/charset.texi @@ -686,28 +686,7 @@ converting all lowercase characters into uppercase could look like this checking, and sometimes leaks memory): @smallexample -wchar_t * -mbstouwcs (const char *s) -@{ - size_t len = strlen (s); - wchar_t *result = malloc ((len + 1) * sizeof (wchar_t)); - wchar_t *wcp = result; - wchar_t tmp[1]; - mbstate_t state; - size_t nbytes; - - memset (&state, '\0', sizeof (state)); - while ((nbytes = mbrtowc (tmp, s, len, &state)) > 0) - @{ - if (nbytes >= (size_t) -2) - /* Invalid input string. */ - return NULL; - *wcp++ = towupper (tmp[0]); - len -= nbytes; - s += nbytes; - @} - return result; -@} +@include mbstouwcs.c.texi @end smallexample The use of @code{mbrtowc} should be clear. A single wide character is |