The function mbrlen() is used to get the length of multibyte character. It returns the size of multibyte character pointed by the pointer.
Here is the syntax of mbrlen() in C language,
size_t mbrlen(const char* pointer, size_t size, mbstate_t* state);
Here,
pointer − Pointer to the first byte of multibyte character.
size − Number of bytes to check.
state − Pointer to the object of mbstate_t
Here is an example of mbrlen() in C language,
Example
#include <stdio.h> #include <stdlib.h> #include <wchar.h> int main(void) { char a[] = "s"; mbstate_t s; int len; len = mbrlen(a, 5, &s); printf("Length of multibyte character : %d \n", len); }
Output
Length of multibyte character : 1
In the above program, we are calculating the length of multibyte character in bytes by using mbrlen() function.
char a[] = "s"; mbstate_t s; int len; len = mbrlen(a, 5, &s);