.\" -*- coding: UTF-8 -*- '\" t .\" Copyright, Bruno Haible .\" Copyright 2014, Michael Kerrisk .\" Copyright, the authors of the Linux man-pages project .\" .\" SPDX-License-Identifier: GPL-2.0-or-later .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .TH mbstowcs 3 "8 février 2026" "Pages du manuel de Linux 6.17" .SH NOM mbstowcs \- Convertir une chaîne de caractères multioctets en une chaîne de caractères larges .SH BIBLIOTHÈQUE Bibliothèque C standard (\fIlibc\fP,\ \fI\-lc\fP) .SH SYNOPSIS .nf \fB#include \fP .P \fBsize_t mbstowcs(\fPsize_t dsize; \fB wchar_t \fP\fIdest\fP\fB[restrict \fP\fIdsize\fP\fB], const char *restrict \fP\fIsrc\fP\fB,\fP \fB size_t \fP\fIdsize\fP\fB);\fP .fi .SH DESCRIPTION Si \fIdest\fP n'est pas un pointeur NULL, convertir la chaîne multioctet \fIsrc\fP en chaîne de caractères larges \fIdest\fP. Elle écrira au plus \fIdsize\fP caractères larges dans \fIdest\fP. La séquence de caractères dans la chaîne \fIsrc\fP commencera dans l'état de décalage initial. La conversion peut s'arrêter pour l'une des trois raisons suivantes\ : .IP \- 3 Une séquence multioctet incorrecte a été rencontrée. Dans ce cas, elle renvoie \fI(size_t)\ \-1\fP. .IP \- \fIdsize\fP non\-L\[aq]\[rs]0\[aq] wide characters have been stored at \fIdest\fP. In this case, the number of wide characters written to \fIdest\fP is returned, but the shift state at this point is lost. .IP \- The multibyte string has been completely converted, including the terminating null character (\[aq]\[rs]0\[aq]). In this case, the number of wide characters written to \fIdest\fP, excluding the terminating null wide character, is returned. .P Si \fIdest\fP est NULL, \fIdsize\fP est ignoré, et la conversion se présente comme au\-dessus, excepté que les caractères larges ne sont pas écrits en mémoire et qu'aucune limite de longueur n'existe. .P Afin d'éviter la situation numéro 2 ci\-dessus, le programmeur doit s'assurer que \fIdsize\fP est supérieur ou égal a \fImbstowcs(NULL,src,0)+1\fP. .P Le programmeur doit s'assurer qu'il y assez de place pour au moins \fIdsize\fP caractères larges dans \fIdest\fP. .SH "VALEUR RENVOYÉE" Le nombre de caractères larges qui constituent la partie convertie de la chaîne, sans compter le caractère large NULL final. Si une séquence multioctet incorrecte est rencontrée, elle renvoie \fI(size_t)\ \-1\fP. .SH ATTRIBUTS Pour une explication des termes utilisés dans cette section, consulter \fBattributes\fP(7). .TS allbox; lbx lb lb l l l. Interface Attribut Valeur T{ .na .nh \fBmbstowcs\fP() T} Sécurité des threads MT\-Safe .TE .SH VERSIONS La fonction \fBmbsrtowcs\fP(3) fournit une meilleure interface pour la même fonctionnalité. .SH NORMES C11, POSIX.1\-2008. .SH HISTORIQUE POSIX.1\-2001, C99. .SH NOTES Le comportement de \fBmbstowcs\fP() dépend de la catégorie \fBLC_CTYPE\fP de la localisation en cours. .SH EXEMPLES Le programme ci\-dessous illustre l’utilisation de \fBmbstowcs\fP(), ainsi que de certaines fonctions de classification pour les caractères larges. Voici un exemple de son exécution. .P .in +4n .EX $ ./t_mbstowcs de_DE.UTF\-8 Grüße! Taille de la chaîne source (sans le caractère final) : 8 octets 6 caractères multioctets \& La chaîne de caractères larges est : Grüße! (6 caractères) G alpha majuscule r alpha minuscule ü alpha minuscule ß alpha minuscule e alpha minuscule ! !alpha .EE .in .SS "Source du programme" .\" SRC BEGIN (mbstowcs.c) \& .EX #include #include #include #include #include #include \& int main(int argc, char *argv[]) { size_t mbslen; /* Number of multibyte characters in source */ wchar_t *wcs; /* Pointer to converted wide character string */ \& if (argc < 3) { fprintf(stderr, "Usage: %s \[rs]n", argv[0]); exit(EXIT_FAILURE); } \& /* Apply the specified locale. */ \& if (setlocale(LC_ALL, argv[1]) == NULL) { perror("setlocale"); exit(EXIT_FAILURE); } \& /* Calculate the length required to hold argv[2] converted to a wide character string. */ \& mbslen = mbstowcs(NULL, argv[2], 0); if (mbslen == (size_t) \-1) { perror("mbstowcs"); exit(EXIT_FAILURE); } \& /* Describe the source string to the user. */ \& printf("Length of source string (excluding terminator):\[rs]n"); printf(" %zu bytes\[rs]n", strlen(argv[2])); printf(" %zu multibyte characters\[rs]n\[rs]n", mbslen); \& /* Allocate wide character string of the desired size. Add 1 to allow for terminating null wide character (L\[aq]\[rs]0\[aq]). */ \& wcs = calloc(mbslen + 1, sizeof(*wcs)); if (wcs == NULL) { perror("calloc"); exit(EXIT_FAILURE); } \& /* Convert the multibyte character string in argv[2] to a wide character string. */ \& if (mbstowcs(wcs, argv[2], mbslen + 1) == (size_t) \-1) { perror("mbstowcs"); exit(EXIT_FAILURE); } \& printf("Wide character string is: %ls (%zu characters)\[rs]n", wcs, mbslen); \& /* Now do some inspection of the classes of the characters in the wide character string. */ \& for (wchar_t *wp = wcs; *wp != 0; wp++) { printf(" %lc ", (wint_t) *wp); \& if (!iswalpha(*wp)) printf("!"); printf("alpha "); \& if (iswalpha(*wp)) { if (iswupper(*wp)) printf("upper "); \& if (iswlower(*wp)) printf("lower "); } \& putchar(\[aq]\[rs]n\[aq]); } \& exit(EXIT_SUCCESS); } .EE .\" SRC END .SH "VOIR AUSSI" \fBmblen\fP(3), \fBmbsrtowcs\fP(3), \fBmbtowc\fP(3), \fBwcstombs\fP(3), \fBwctomb\fP(3) .PP .SH TRADUCTION La traduction française de cette page de manuel a été créée par Christophe Blaess , Stéphan Rafin , Thierry Vignaud , François Micaux, Alain Portal , Jean-Philippe Guérard , Jean-Luc Coulon (f5ibh) , Julien Cristau , Thomas Huriaux , Nicolas François , Florentin Duneau , Simon Paillard , Denis Barbier et David Prévot . .PP Cette traduction est une documentation libre ; veuillez vous reporter à la .UR https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License version 3 .UE concernant les conditions de copie et de distribution. Il n'y a aucune RESPONSABILITÉ LÉGALE. .PP Si vous découvrez un bogue dans la traduction de cette page de manuel, veuillez envoyer un message à .MT debian-l10n-french@lists.debian.org .ME .