size_t mbrlen(const char* kcpMChar, size_t qMaxSize, mbstate_t qMBState);
The call can fail for several reasons and will return the following:
0 if "kcpMChar" points to the NULL wide character
-1 if "kcpMChar" does not point to a valid multibyte character
-2 if "qMaxSize" is not large enough to contain the character
#include <iostream>
#include <cwchar>
int main()
{
using namespace std;
char* cpName = "XoaX.txt";
// Get the length to the end of the first character.
size_t qReturn = mbrlen(cpName, MB_CUR_MAX, NULL);
// Check whether the call was successful.
if (qReturn < 0) {
cout << "Error!" << endl;
} else {
cout << "Char length = " << qReturn << endl;
}
return 0;
}
© 20072025 XoaX.net LLC. All rights reserved.