mbrtowc
Table des matières
Retour à l'index
NOM
mbrtowc - Convertir une séquence multioctet en caractère large
BIBLIOTHÈQUE
Bibliothèque C standard (libc, -lc)
SYNOPSIS
#include <wchar.h>
size_t mbrtowc(wchar_t *restrict pwc, const char s[restrict .n],
size_t n, mbstate_t *restrict ps);
DESCRIPTION
The main case for this function is when s is not NULL and pwc is not
NULL. In this case, the mbrtowc() function inspects at most n bytes
of the multibyte string starting at s, extracts the next complete
multibyte character, converts it to a wide character and stores it at
*pwc. It updates the shift state *ps. If the converted wide
character is not L'\0' (the null wide character), it returns the
number of bytes that were consumed from s. If the converted wide
character is L'\0', it resets the shift state *ps to the
initial state and returns 0.
Si les n octets commençant en s ne contiennent pas de caractère large
complet, mbrtowc() renvoie (size_t) -2. Cela peut se produire même si
n >= MB_CUR_MAX, lorsque la séquence multioctet contient des
séquences de décalage redondantes.
Si la séquence multioctet commençant en s contient une séquence invalide
avant le prochain caractère complet, mbrtowc() renvoie (size_t) -1 et
place dans errno la valeur EILSEQ. Dans ce cas, les effets sur *ps
sont indéfinis.
Une autre situation est possible, si s est non NULL, mais pwc est
NULL. Dans ce cas, mbrtowc() se comporte comme précédemment, mais
n'enregistre pas le caractère large obtenu.
Un troisième cas se présente si s est NULL. Alors, pwc et n sont
ignorés. Si l'état de conversion représenté par *ps indique une
conversion multioctet incomplète, la fonction mbrtowc() renvoie
(size_t) -1, remplie errno avec EILSEQ, et laisse *ps dans un
état indéfini. Sinon, la fonction mbrtowc() replace *ps dans l'état
initial et renvoie 0.
Dans tous ces cas, si ps est un pointeur NULL, une zone de mémoire
statique propre à mbrtowc() est utilisée à sa place. Sinon, *ps doit
être un objet mbstate_t valide. Un tel objet mbstate_t noté a peut
être initialisé en le mettant à zéro, par exemple ainsi :
memset(&a, 0, sizeof(a));
VALEUR RENVOYÉE
The mbrtowc() function returns the number of bytes parsed from the
multibyte sequence starting at s, if a non-L'\0' wide
character was recognized. It returns 0, if a L'\0' wide
character was recognized. It returns (size_t) -1 and sets errno to
EILSEQ, if an invalid multibyte sequence was encountered. It returns
(size_t) -2 if it couldn't parse a complete multibyte character, meaning
that n should be increased.
ATTRIBUTS
Pour une explication des termes utilisés dans cette section, consulter
attributes(7).
| Interface | Attribut | Valeur
|
|
mbrtowc()
| Sécurité des threads | MT-Unsafe race:mbrtowc/!ps
|
STANDARDS
C11, POSIX.1-2008.
HISTORIQUE
POSIX.1-2001, C99.
NOTES
Le comportement de mbrtowc() dépend de la catégorie LC_CTYPE de la
localisation en cours.
VOIR AUSSI
mbsinit(3), mbsrtowcs(3)
TRADUCTION
La traduction française de cette page de manuel a été créée par
Christophe Blaess <https://www.blaess.fr/christophe/>,
Stéphan Rafin <stephan.rafin@laposte.net>,
Thierry Vignaud <tvignaud@mandriva.com>,
François Micaux,
Alain Portal <aportal@univ-montp2.fr>,
Jean-Philippe Guérard <fevrier@tigreraye.org>,
Jean-Luc Coulon (f5ibh) <jean-luc.coulon@wanadoo.fr>,
Julien Cristau <jcristau@debian.org>,
Thomas Huriaux <thomas.huriaux@gmail.com>,
Nicolas François <nicolas.francois@centraliens.net>,
Florentin Duneau <fduneau@gmail.com>,
Simon Paillard <simon.paillard@resel.enst-bretagne.fr>,
Denis Barbier <barbier@debian.org>,
David Prévot <david@tilapin.org>,
Jean-Baptiste Holcroft <jean-baptiste@holcroft.fr>
et
Grégoire Scano <gregoire.scano@malloc.fr>
Cette traduction est une documentation libre ; veuillez vous reporter à la
GNU General Public License version 3
concernant les conditions de copie et
de distribution. Il n'y a aucune RESPONSABILITÉ LÉGALE.
Si vous découvrez un bogue dans la traduction de cette page de manuel,
veuillez envoyer un message à
Index
- NOM
-
- BIBLIOTHÈQUE
-
- SYNOPSIS
-
- DESCRIPTION
-
- VALEUR RENVOYÉE
-
- ATTRIBUTS
-
- STANDARDS
-
- HISTORIQUE
-
- NOTES
-
- VOIR AUSSI
-
- TRADUCTION
-
This document was created by
man2html,
using the manual pages.
Time: 05:06:20 GMT, September 19, 2025