OK I'm using VC++ and I've read the MSDN description at
wcsrtombs_s
but I've obviously misunderstood something.
The following function is supposed to produce a popup window with the message given in 'str'. When compiled as a Unicode program the wide string str needs to be converted into a UTF-8 string for fl_message. What I actually get is a null string for 'copiedstring'.
Possibly this has something to do with the setlocale function?
Any hints gratefully received.
Code:void pbox(const _TCHAR *str)
{
char copiedstring[250];
mbstate_t mbstate;
size_t retval;
#ifdef _UNICODE
// setlocale(LC_CTYPE, "en_US.UTF-8");
// Convert to UTF-8 from wchar_t
// Reset to initial conversion state
const wchar_t *wcsIndirectString = str;
memset(&mbstate, 0, sizeof(mbstate));
wcsrtombs_s(&retval, copiedstring, sizeof(copiedstring), &str, 249, &mbstate);
fl_message(copiedstring);
#else
fl_message(str);
#endif
}