Scroll to navigation

wcstombs(3) Library Functions Manual wcstombs(3)

NOMBRE

wcstombs - convierte una cadena de caracteres anchos a una cadena mulibyte

BIBLIOTECA

Biblioteca Estándar C (libc-lc)

SINOPSIS

#include <stdlib.h>
size_t wcstombs(size_t dsize;
                char dest[restrict dsize], const wchar_t *restrict src,
                size_t dsize);

DESCRIPCIÓN

If dest is not NULL, the wcstombs() function converts the wide-character string src to a multibyte string starting at dest. At most dsize bytes are written to dest. The sequence of characters placed in dest begins in the initial shift state. The conversion can stop for three reasons:

Se ha encontrado un carácter ancho que no se puede representar como una secuencia multibyte (de acuerdo con la localización actual). En este caso se devuelve (size_t) -1.
El límite de longitud fuerza la parada. En este caso, devuelve el número de bytes escritos en dest pero el estado de cambios en este punto se pierde.
The wide-character string has been completely converted, including the terminating null wide character (L'\0'). In this case, the conversion ends in the initial shift state. The number of bytes written to dest, excluding the terminating null byte ('\0'), is returned.

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

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

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

VALOR DEVUELTO

La función wcstombs() devuelve el número de bytes que conforman la parte de la secuencia multibyte convertida, sin incluir el byte nulo terminador. Si encontró un carácter ancho que no pudo convertir, devuelve (size_t) -1.

ATRIBUTOS

Para obtener una explicación de los términos usados en esta sección, véase attributes(7).

Interfaz Atributo Valor
wcstombs() Seguridad del hilo Multi-hilo seguro

VERSIONES

La función wcsrtombs(3) proporciona un interfaz seguro para hilos con la misma funcionalidad.

ESTÁNDARES

C11, POSIX.1-2008.

HISTORIAL

POSIX.1-2001, C99.

NOTAS

El comportamiento de wcstombs() depende de la categoría LC_CTYPE de la localización actual.

VÉASE TAMBIÉN

mblen(3), mbstowcs(3), mbtowc(3), wcsrtombs(3), wctomb(3)

TRADUCCIÓN

La traducción al español de esta página del manual fue creada por Pedro Pablo Fábrega <pfabrega@arrakis.es> y Juan Piernas <piernas@ditec.um.es>

Esta traducción es documentación libre; lea la GNU General Public License Version 3 o posterior con respecto a las condiciones de copyright. No existe NINGUNA RESPONSABILIDAD.

Si encuentra algún error en la traducción de esta página del manual, envíe un correo electrónico a debian-l10n-spanish@lists.debian.org.

7 Septiembre 2025 Páginas de Manual de Linux 6.16