mbsrtowcs(3) Library Functions Manual mbsrtowcs(3)

mbsrtowcs - convert a multibyte string to a wide-character string (restartable)

Bibliothèque C standard (libc, -lc)

#include <wchar.h>
size_t mbsrtowcs(wchar_t dest[restrict .dsize], const char **restrict src,
                 size_t dsize, mbstate_t *restrict ps);

If dest is not NULL, convert the multibyte string *src to a wide-character string starting at dest. At most dsize wide characters are written to dest. The shift state *ps is updated. The conversion is effectively performed by repeatedly calling mbrtowc(dest, *src, n, ps) where n is some positive number, as long as this call succeeds, and then incrementing dest by one and *src by the number of bytes consumed. The conversion can stop for three reasons:

  • Une séquence multioctet incorrecte a été rencontrée. Dans ce cas, *src pointera sur la séquence incorrecte, et la fonction renvoie (size_t) -1 en positionnant errno à la valeur EILSEQ.
  • dsize non-L'\0' wide characters have been stored at dest. In this case, *src is left pointing to the next multibyte sequence to be converted, and the number of wide characters written to dest is returned.
  • La séquence multioctet a été complètement convertie, y compris le caractère nul ('\0') final, ce qui a pour effet de bord de ramener *ps à l'état initial. Dans ce cas, *src est mis à NULL, et le nombre de caractères écrits dans dest, moins le caractère large nul final, est renvoyé.

If dest is NULL, dsize is ignored, and the conversion proceeds as above, except that the converted wide characters are not written out to memory, and that no length limit exists.

Dans tous les cas, si ps est un pointeur NULL, un état anonyme statique, réservé à la fonction mbsnrtowcs() est utilisé à sa place.

In order to avoid the case 2 above, the programmer should make sure dsize is greater than or equal to mbsrtowcs(NULL,src,0,ps)+1.

The programmer must ensure that there is room for at least dsize wide characters at dest.

This function is a restartable version of mbstowcs(3).

The number of wide characters that make up the converted part of the wide-character string, not including the terminating null wide character. If an invalid multibyte sequence was encountered, (size_t) -1 is returned, and errno set to EILSEQ.

Pour une explication des termes utilisés dans cette section, consulter attributes(7).

Interface Attribut Valeur
mbsrtowcs() Sécurité des threads MT-Unsafe race:mbsrtowcs/!ps

C11, POSIX.1-2008.

POSIX.1-2001, C99.

Le comportement de mbsrtowcs() dépend de la catégorie LC_CTYPE de la localisation en cours.

Passer NULL dans ps n'est pas sûr dans un contexte multithread.

iconv(3), mbrtowc(3), mbsinit(3), mbsnrtowcs(3), mbstowcs(3)

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 à debian-l10n-french@lists.debian.org.

19 novembre 2023 Pages du manuel de Linux 6.06