]>
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 | |
16 | mbsrtowcs \- convert a multibyte string to a wide character string | |
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 | |
e511ffb6 | 25 | If \fIdest\fP is not a NULL pointer, the \fBmbsrtowcs\fP() function converts the |
fea681da | 26 | multibyte string \fI*src\fP to a wide-character string starting at \fIdest\fP. |
c13182ef MK |
27 | At most \fIlen\fP wide characters are written to \fIdest\fP. |
28 | The shift state | |
29 | \fI*ps\fP is updated. | |
30 | The conversion is effectively performed by repeatedly | |
fea681da MK |
31 | calling mbrtowc(\fIdest\fP,\fI*src\fP,\fIn\fP,\fIps\fP) where \fIn\fP is some |
32 | positive number, as long as this call succeeds, and then incrementing | |
c13182ef MK |
33 | \fIdest\fP by one and \fI*src\fP by the number of bytes consumed. |
34 | The conversion can stop for three reasons: | |
fea681da | 35 | .PP |
c13182ef MK |
36 | 1. An invalid multibyte sequence has been encountered. |
37 | In this case \fI*src\fP | |
2bc2f479 | 38 | is left pointing to the invalid multibyte sequence, (size_t)(\-1) is returned, |
dcec8eb5 | 39 | and \fIerrno\fP is set to \fBEILSEQ\fP. |
fea681da | 40 | .PP |
c13182ef MK |
41 | 2. \fIlen\fP non-L'\\0' wide characters have been stored at \fIdest\fP. |
42 | In this | |
fea681da MK |
43 | case \fI*src\fP is left pointing to the next multibyte sequence to be converted, |
44 | and the number of wide characters written to \fIdest\fP is returned. | |
45 | .PP | |
46 | 3. The multibyte string has been completely converted, including the | |
47 | terminating '\\0' (which has the side effect of bringing back \fI*ps\fP to the | |
c13182ef MK |
48 | initial state). |
49 | In this case \fI*src\fP is set to NULL, and the number of wide | |
fea681da MK |
50 | characters written to \fIdest\fP, excluding the terminating L'\\0' character, |
51 | is returned. | |
52 | .PP | |
53 | If \fIdest\fP is NULL, \fIlen\fP is ignored, and the conversion proceeds as | |
54 | above, except that the converted wide characters are not written out to memory, | |
55 | and that no length limit exists. | |
56 | .PP | |
57 | In both of the above cases, if \fIps\fP is a NULL pointer, a static anonymous | |
58 | state only known to the mbsrtowcs function is used instead. | |
59 | .PP | |
60 | The programmer must ensure that there is room for at least \fIlen\fP wide | |
61 | characters at \fIdest\fP. | |
62 | .SH "RETURN VALUE" | |
e511ffb6 | 63 | The \fBmbsrtowcs\fP() function returns the number of wide characters that make |
fea681da | 64 | up the converted part of the wide character string, not including the |
c13182ef MK |
65 | terminating null wide character. |
66 | If an invalid multibyte sequence was | |
dcec8eb5 | 67 | encountered, (size_t)(\-1) is returned, and \fIerrno\fP set to \fBEILSEQ\fP. |
fea681da | 68 | .SH "CONFORMING TO" |
68e1685c | 69 | C99 |
fea681da MK |
70 | .SH "SEE ALSO" |
71 | .BR iconv (3), | |
72 | .BR mbsnrtowcs (3), | |
73 | .BR mbstowcs (3) | |
74 | .SH NOTES | |
e511ffb6 | 75 | The behaviour of \fBmbsrtowcs\fP() depends on the LC_CTYPE category of the |
fea681da MK |
76 | current locale. |
77 | .PP | |
78 | Passing NULL as \fIps\fP is not multi-thread safe. |