]>
Commit | Line | Data |
---|---|---|
fea681da MK |
1 | .\" Copyright (c) Bruno Haible <haible@clisp.cons.org> |
2 | .\" | |
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. | |
7 | .\" | |
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 | |
12 | .\" ISO/IEC 9899:1999 | |
13 | .\" | |
14 | .TH MBSRTOWCS 3 1999-07-25 "GNU" "Linux Programmer's Manual" | |
15 | .SH NAME | |
d0f17b57 | 16 | mbsrtowcs \- convert a multibyte string to a wide-character string |
fea681da MK |
17 | .SH SYNOPSIS |
18 | .nf | |
19 | .B #include <wchar.h> | |
20 | .sp | |
21 | .BI "size_t mbsrtowcs(wchar_t *" dest ", const char **" src , | |
22 | .BI " size_t " len ", mbstate_t *" ps ); | |
23 | .fi | |
24 | .SH DESCRIPTION | |
60a90ecd MK |
25 | If \fIdest\fP is not a NULL pointer, the |
26 | .BR mbsrtowcs () | |
27 | function converts the | |
fea681da | 28 | multibyte string \fI*src\fP to a wide-character string starting at \fIdest\fP. |
c13182ef MK |
29 | At most \fIlen\fP wide characters are written to \fIdest\fP. |
30 | The shift state | |
31 | \fI*ps\fP is updated. | |
32 | The conversion is effectively performed by repeatedly | |
657e762d | 33 | calling |
0daa9e92 | 34 | .I "mbrtowc(dest, *src, n, ps)" |
657e762d | 35 | where \fIn\fP is some |
fea681da | 36 | positive number, as long as this call succeeds, and then incrementing |
c13182ef MK |
37 | \fIdest\fP by one and \fI*src\fP by the number of bytes consumed. |
38 | The conversion can stop for three reasons: | |
fea681da | 39 | .PP |
c13182ef MK |
40 | 1. An invalid multibyte sequence has been encountered. |
41 | In this case \fI*src\fP | |
7d2cb9d5 | 42 | is left pointing to the invalid multibyte sequence, |
009df872 | 43 | .I (size_t)\ \-1 |
7d2cb9d5 | 44 | is returned, |
dcec8eb5 | 45 | and \fIerrno\fP is set to \fBEILSEQ\fP. |
fea681da | 46 | .PP |
c13182ef MK |
47 | 2. \fIlen\fP non-L'\\0' wide characters have been stored at \fIdest\fP. |
48 | In this | |
d9a10d9d MK |
49 | case \fI*src\fP is left pointing to the next |
50 | multibyte sequence to be converted, | |
fea681da MK |
51 | and the number of wide characters written to \fIdest\fP is returned. |
52 | .PP | |
53 | 3. The multibyte string has been completely converted, including the | |
d9a10d9d MK |
54 | terminating '\\0' (which has the side |
55 | effect of bringing back \fI*ps\fP to the | |
c13182ef MK |
56 | initial state). |
57 | In this case \fI*src\fP is set to NULL, and the number of wide | |
d9a10d9d MK |
58 | characters written to \fIdest\fP, |
59 | excluding the terminating L'\\0' character, is returned. | |
fea681da | 60 | .PP |
d9a10d9d MK |
61 | If \fIdest\fP is NULL, \fIlen\fP is ignored, |
62 | and the conversion proceeds as above, | |
63 | except that the converted wide characters are not written out to memory, | |
fea681da MK |
64 | and that no length limit exists. |
65 | .PP | |
d9a10d9d MK |
66 | In both of the above cases, |
67 | if \fIps\fP is a NULL pointer, a static anonymous | |
68 | state only known to the | |
69 | .BR mbsrtowcs () | |
70 | function is used instead. | |
fea681da MK |
71 | .PP |
72 | The programmer must ensure that there is room for at least \fIlen\fP wide | |
73 | characters at \fIdest\fP. | |
74 | .SH "RETURN VALUE" | |
60a90ecd MK |
75 | The |
76 | .BR mbsrtowcs () | |
77 | function returns the number of wide characters that make | |
d0f17b57 | 78 | up the converted part of the wide-character string, not including the |
c13182ef MK |
79 | terminating null wide character. |
80 | If an invalid multibyte sequence was | |
7d2cb9d5 | 81 | encountered, |
009df872 | 82 | .I (size_t)\ \-1 |
7d2cb9d5 | 83 | is returned, and \fIerrno\fP set to \fBEILSEQ\fP. |
fea681da | 84 | .SH "CONFORMING TO" |
68e1685c | 85 | C99 |
fea681da | 86 | .SH NOTES |
d9bfdb9c | 87 | The behavior of |
60a90ecd | 88 | .BR mbsrtowcs () |
1274071a MK |
89 | depends on the |
90 | .B LC_CTYPE | |
91 | category of the | |
fea681da MK |
92 | current locale. |
93 | .PP | |
94 | Passing NULL as \fIps\fP is not multi-thread safe. | |
e37e3282 MK |
95 | .SH "SEE ALSO" |
96 | .BR iconv (3), | |
97 | .BR mbsnrtowcs (3), | |
98 | .BR mbstowcs (3) |