.\" -*- coding: UTF-8 -*- '\" t .\" Copyright (c) Bruno Haible .\" and Copyright 2014 Michael Kerrisk .\" .\" SPDX-License-Identifier: GPL-2.0-or-later .\" .\" References consulted: .\" GNU glibc-2 source code and manual .\" Dinkumware C library reference http://www.dinkumware.com/ .\" OpenGroup's Single UNIX specification http://www.UNIX-systems.org/online.html .\" ISO/IEC 9899:1999 .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .TH mbstowcs 3 "14 novembre 2023" "Pages du manuel de Linux 6.06" .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(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 If \fIdest\fP is not NULL, convert the multibyte string \fIsrc\fP to a wide\-character string starting at \fIdest\fP. At most \fIdsize\fP wide characters are written to \fIdest\fP. The sequence of characters in the string \fIsrc\fP shall begin in the initial shift state. The conversion can stop for three reasons: .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]\e0\[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 \- La chaîne multioctet a été complètement convertie, y compris le caractère NULL final («\ \e0\ »). Dans ce cas, le nombre de caractères larges écrits dans \fIdest\fP, sans compter le caractère large NULL final, est renvoyé. .P If \fIdest\fP is NULL, \fIdsize\fP 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. .P In order to avoid the case 2 above, the programmer should make sure \fIdsize\fP is greater than or equal to \fImbstowcs(NULL,src,0)+1\fP. .P The programmer must ensure that there is room for at least \fIdsize\fP wide characters at \fIdest\fP. .SH "VALEUR RENVOYÉE" 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, \fI(size_t)\ \-1\fP is returned. .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 STANDARDS 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! Length of source string (excluding terminator): 8 bytes 6 multibyte characters \& Wide character string is: Grüße! (6 characters) G alpha upper r alpha lower ü alpha lower ß alpha lower e alpha lower ! !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 \en", 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):\en"); printf(" %zu bytes\en", strlen(argv[2])); printf(" %zu multibyte characters\en\en", mbslen); \& /* Allocate wide character string of the desired size. Add 1 to allow for terminating null wide character (L\[aq]\e0\[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)\en", 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]\en\[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 .