mbrtowc(3) Library Functions Manual mbrtowc(3) NOMBRE mbrtowc - convierte una secuencia multibyte a un caracter ancho BIBLIOTECA Biblioteca Estandar C (libc, -lc) SINOPSIS #include size_t mbrtowc(size_t n; wchar_t *restrict pwc, const char s[restrict n], size_t n, mbstate_t *restrict ps); DESCRIPCION 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 los n bytes que comienzan en s no contienen un caracter multibyte completo, mbrtowc() devuelve (size_t) -2. Esto puede ocurrir incluso si n >= MB_CUR_MAX, si la cadena multibyte contiene secuencias de cambios redundantes. Si la cadena multibyte que comienza en s contiene una secuencia multibyte invalida antes del siguiente caracter completo, mbrtowc() devuelve (size_t) -1 y asigna a errno el valor EILSEQ. En este caso, los efectos sobre *ps son indefinidos. Un caso diferente se da cuando s no es NULL pero pwc es NULL. En este caso, la funcion mbrtowc() se comporta como antes, excepto que no almacena el caracter ancho obtenido en memoria. Un tercer caso se da cuando s es NULL. En este caso, pwc y n se ignoran. Si el estado de conversion representado por *ps indica una conversion incompleta de caracteres multibyte, la funcion mbrtowc() devuelve (size_t) -1, asigna a errno el valor EILSEQ, y deja *ps en un estado indefinido. En otro caso, la funcion mbrtowc() coloca *ps en el estado inicial y devuelve 0. In all of the above cases, if ps is NULL, a static anonymous state known only to the mbrtowc() function is used instead. Otherwise, *ps must be a valid mbstate_t object. An mbstate_t object a can be initialized to the initial state by zeroing it, for example using memset(&a, 0, sizeof(a)); VALOR DEVUELTO 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 the consumed n bytes form a valid partial character sequence; more subsequent data needs to be fed in. ATRIBUTOS Para obtener una explicacion de los terminos usados en esta seccion, vease attributes(7). +--------------------+--------------------+----------------------------+ |Interfaz | Atributo | Valor | +--------------------+--------------------+----------------------------+ |mbrtowc() | Seguridad del hilo | MT-Unsafe race:mbrtowc/!ps | +--------------------+--------------------+----------------------------+ ESTANDARES C11, POSIX.1-2008. HISTORIAL POSIX.1-2001, C99. NOTAS El comportamiento de mbrtowc() depende de la categoria LC_CTYPE de la localizacion actual. VEASE TAMBIEN mbsinit(3), mbsrtowcs(3) TRADUCCION La traduccion al espanol de esta pagina del manual fue creada por Juan Piernas Esta traduccion es documentacion libre; lea la GNU General Public License Version 3 o posterior con respecto a las condiciones de copyright. No existe NINGUNA RESPONSABILIDAD. Si encuentra algun error en la traduccion de esta pagina del manual, envie un correo electronico a . Linux man-pages 6.18 8 Febrero 2026 mbrtowc(3)