I've tried implementing a function like this, but unfortunately it doesn't work:
const wchar_t *GetWC(const char *c) { const size_t cSize = strlen(c)+1; wchar_t wc[cSize]; mbstowcs (wc, c, cSize); return wc; } My main goal here is to be able to integrate normal char strings in a Unicode application. Any advice you guys can offer is greatly appreciated.
strlen()is wrong, you would need to use something likembslen()instead [which is done withmbstowcs(NULL, ...)]. UTF-8 does not have the same number of characters. Also wchar_t under MS-Windows uses UTF-16 which adds another fun thing to take in account when measuring the string length.