1 .\" Copyright (c) Bruno Haible <haible@clisp.cons.org>
3 .\" This is free documentation; you can redistribute it and/or
4 .\" modify it under the terms of the GNU General Public License as
5 .\" published by the Free Software Foundation; either version 2 of
6 .\" the License, or (at your option) any later version.
8 .\" References consulted:
9 .\" GNU glibc-2 source code and manual
10 .\" Dinkumware C library reference http://www.dinkumware.com/
11 .\" OpenGroup's Single UNIX specification http://www.UNIX-systems.org/online.html
14 .TH MBTOWC 3 2011-09-28 "GNU" "Linux Programmer's Manual"
16 mbtowc \- convert a multibyte sequence to a wide character
19 .B #include <stdlib.h>
21 .BI "int mbtowc(wchar_t *" pwc ", const char *" s ", size_t " n );
24 The main case for this function is when \fIs\fP is not NULL and \fIpwc\fP is
28 function inspects at most \fIn\fP
29 bytes of the multibyte string starting at \fIs\fP,
30 extracts the next complete
31 multibyte character, converts it to a wide character and stores it at
33 It updates an internal shift state only known to the mbtowc
35 If \fIs\fP does not point to a null byte (\(aq\\0\(aq), it returns the number
36 of bytes that were consumed from \fIs\fP, otherwise it returns 0.
38 If the \fIn\fP bytes starting at \fIs\fP do not contain a complete multibyte
39 character, or if they contain an invalid multibyte sequence,
42 This can happen even if \fIn\fP >= \fIMB_CUR_MAX\fP,
43 if the multibyte string contains redundant shift sequences.
45 A different case is when \fIs\fP is not NULL but \fIpwc\fP is NULL.
49 function behaves as above, except that it does not
50 store the converted wide character in memory.
52 A third case is when \fIs\fP is NULL.
53 In this case, \fIpwc\fP and \fIn\fP are
58 .\" The Dinkumware doc and the Single UNIX specification say this, but
59 .\" glibc doesn't implement this.
60 resets the shift state, only known to this function,
61 to the initial state, and
62 returns nonzero if the encoding has nontrivial shift state, or zero if the
63 encoding is stateless.
65 If \fIs\fP is not NULL, the
67 function returns the number of
68 consumed bytes starting at \fIs\fP, or 0 if \fIs\fP points to a null byte,
71 If \fIs\fP is NULL, the
74 returns nonzero if the encoding
75 has nontrivial shift state, or zero if the encoding is stateless.
86 This function is not multithread safe.
90 a better interface to the same functionality.