I was trying to use wcstombs_s to convert my Japanese wstring into multibyte char but am getting empty string . Here's what i was doing my first approach using wcstombs_s -
wstring str = "ス";
char * outputString;
size_t outputSize = str.length() + 1; // +1 for null terminator
outputString = new char[outputSize];
size_t charsConverted = 0;
const wchar_t * inputW = str.c_str();
wcstombs_s(&charsConverted, outputString, outputSize, inputW, str.length());
i receive empty string in inputW,
I also tried using builtin api WideCharToMultiByte here also am not getting the expected output. Here's what i am doing could anyone tell me where am doing the mistake -
char *nstringw = new char[256];
size_t status = WideCharToMultiByte( 932U, 0, str.c_str(), static_cast<int>(str.length() + 1), nstringw, 256, nullptr, nullptr);
i receive the same number of characters in nstringw but junk value. I am just reading the text field value and want to convert it.
Aucun commentaire:
Enregistrer un commentaire