I need to convert a const std::wstring * to a UTF-8 encoded const char * and I just can't make it work.
I wrote the code to do that but it isn't working
But while wideData->c_str() looks fine and wideData->size() too, after wcstombs count turns into 4 billion something, and convertedChar is just "". But if I replace the last line withCode://wideData is defined as const std::wstring *wideData size_t count = 0; char *convertedChar = new char[wideData->size() + 1]; count = wcstombs(convertedChar, wideData->c_str(), wideData->size());
Then count is 4 and convertedChar is "test" so it is working there. What am I doing wrong?Code:count = wcstombs(convertedChar, L"test", wideData->size());
Thanks in advance



LinkBack URL
About LinkBacks



Anyway, is it really that important? The value of the wstring is fine, the debugger shows that the text is the exactly the same as the text in the file.
CornedBee