Высчитать количество байт в строке из многобайтовых символов (с повторным запуском)
#include <wchar.h>
size_t mbrlen( const char *s,
size_t n,
mbstate_t *ps);
- s
- A pointer to a multibyte character.
- n
- The maximum number of bytes that you want to count.
- ps
- An internal pointer that lets mbrlen() be a restartable version of mblen(); if ps is
NULL
, mbrlen() uses its own internal variable. You can call mbsinit() to determine the status of this variable.
libc
The mbrlen() function counts the bytes in the multibyte character pointed to by s, to a maximum of n bytes.
- (size_t)-2
- The resulting conversion state indicates an incomplete multibyte character after all n characters were converted.
- (size_t)-1
- The function detected an encoding error before completing the next multibyte character, in which case the function errno to
EILSEQ
and leaves the resulting conversion state undefined.
- 0
- The next completed character is a null character, in which case the resulting conversion state is the initial conversion state.
- x
- The number of bytes needed to complete the next multibyte character, in which case the resulting conversion state indicates that x bytes have been converted.
- EILSEQ
- Invalid character sequence.
- EINVAL
- The ps argument points to an invalid object.
ANSI, POSIX 1003.1
- Точка остановки потока
- Нет
- Обработчик прерываний
- Нет
- Обработчик сигналов
- Да
- В потоке
- Да
errno mblen(), mbrtowc(), mbsinit(), mbsrtowcs(), mbstowcs(), mbtowc()
Предыдущий раздел: Описание API системной библиотеки