int mbtowc(wchar_t* wpString, const char* kcpMultibyteString, size_t qMaxBytes);
#include <iostream> #include <cstdlib> int main() { using namespace std; wchar_t wWideChar = L'X'; char* cpMultibyteChar = new char[MB_CUR_MAX + 1]; int iConvertLength = wctomb(cpMultibyteChar, wWideChar); // Null terminate the chars cpMultibyteChar[iConvertLength] = 0; // Convert to a multibyte char cout << "Conversion Length = " << iConvertLength << endl; cout << "Conversion = " << cpMultibyteChar << endl; // Convert back to a wide char wchar_t wConvWideChar; int iConvertedBack = mbtowc(&wConvWideChar, cpMultibyteChar, MB_CUR_MAX); cout << "Conversion Back Length = " << iConvertedBack << endl; cout << "Value of Conversion Back = " << wConvWideChar << endl; }
© 20072024 XoaX.net LLC. All rights reserved.