##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# mbrlen

From cppreference.com
< c‎ | string‎ | multibyte

Defined in header `<wchar.h>` |  |
size_t mbrlen( const char* s, size_t n, mbstate_t* ps ); |  |

Determines the size, in bytes, of the remainder of the multibyte character whose first byte is pointed to by `s`, given the current conversion state `ps`.

This function is equivalent to the call mbrtowc(nullptr, s, n, ps?ps:&internal) for some hidden object `internal` of type mbstate_t, except that the expression `ps` is evaluated only once.

### [edit] Parameters

s | - | pointer to an element of a multibyte character string
n | - | limit on the number of bytes in s that can be examined
ps | - | pointer to the variable holding the conversion state

### [edit] Return value

​0​ if the next `n` or fewer bytes complete the null character.

The number of bytes (between 1 and n) that complete a valid multibyte character

(size_t)-1 if encoding error occurs

(size_t)-2 if the next `n` bytes are part of a possibly valid multibyte character, which is still incomplete after examining all `n` bytes

### [edit] Example

| This section is incomplete Reason: no example

### [edit] See also

mbrtowc | converts the next multibyte character to wide character, given state (function) [edit]
mblen | returns the number of bytes in the next multibyte character (function) [edit]
C++ documentation for mbrlen

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=c/string/multibyte/mbrlen&oldid=56791"
Category:

- Todo no example