The mbrlen() function in C/C++ determines the size in bytes, of the remainder of the multibyte character whose first byte is pointed to by str, given the current conversion state ps. The behavior of this function depends on the LC_CTYPE category of the selected C locale.
size_t mbrlen( const char* str, size_t n, mbstate_t* ps)
Parameters: The function accepts three mandatory parameters which are described below:
- str: specifies the pointer to the first byte of multibyte string to examine
- n: specifies the mAximum number of bytes in s to examine
- ps: specifies the pointer to mbstate_t object that defines a conversion state
Return value : The function returns four value as below:
- the number of bytes which complete a valid multibyte character
- -1 if encoding error occurs
- 0 if s points to null character
- -2 if the next n bytes are part of a possibly valid multibyte character, which is still incomplete after examining all n bytes
Below programs illustrate the above function:
Program 1 :
Next 1 byte(s) doesn't represent a complete multibyte character Next 6 byte(s) of á??0b5holds 3 byte multibyte character
Next 1 byte(s) of holds 0 byte multibyte character Next 3 byte(s) of holds 0 byte multibyte character
- How to call some function before main() function in C++?
- Function Overloading vs Function Overriding in C++
- What happens when a virtual function is called inside a non-virtual function in C++
- Difference between Virtual function and Pure virtual function in C++
- div() function in C++
- arc function in C
- log() function in C++
- exp() function C++
- fma() function in C++
- iswspace() function in C/C++
- strcspn() function in C/C++
- unordered_map end( ) function in C++ STL
- array at() function in C++ STL
- array get() function in C++ STL
- transform_inclusive_scan() function in C++
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.