I have a weird problem and I want to know if any of you have any ideas on how to fix this.
If I do this...
swprintf(Dest, 500, L"G%sY", "AMEDA");
(wchar_t*)Dest contains the following text...
GAMEDAY
But if I do this...
swprintf(Dest, 500, L"G%sY", L"AMEDA");
(wchar_t*)Dest now contains...
GAY
So it seems that the compiler is converting the text to a wide character array, but swprintf() still thinks that %s is pointing to a simple character array. I've tried this too...
swprintf(Dest, 500, L"G%sY", (const wchar_t *)L"AMEDA");
Same thing happens.
I know this is supposed to work because according to THIS site...
If no l modifier is present: The ''const char *'' argument is expected to be a pointer to an array of character type (pointer to a string) containing a multibyte character sequence beginning in the initial shift state. Characters from the array are converted to wide characters (each by a call to the mbrtowc() function with a conversion state starting in the initial state before the first byte). The resulting wide characters are written up to (but not including) the terminating null wide character. If a precision is specified, no more wide characters than the number specified are written. Note that the precision determines the number of wide characters written, not the number of bytes or screen positions. The array must contain a terminating null byte, unless a precision is given and it is so small that the number of converted wide characters reaches it before the end of the array is reached. If an l modifier is present: The ''const wchar_t *'' argument is expected to be a pointer to an array of wide characters. Wide characters from the array are written up to (but not including) a terminating null wide character. If a precision is specified, no more than the number specified are written. The array must contain a terminating null wide character, unless a precision is given and it is smaller than or equal to the number of wide characters in the array.
I am using the latest GCC in the latest Ubuntu. Any ideas?