If you set the locale, it should be fine. To pick up the environment variable you can do this:
setlocale(LC_CTYPE, ""); // include <locale.h>
or set it explicitly. This is because all of the output functions need to know which encoding to use.
OS X is failing to perform the vswprintf
at all, while Linux runs it (though the characters will be incorrect if printed).
Here's the relevant section from the glibc documentation:
If the format string contains non-ASCII wide characters, the program will only work correctly if the LC_CTYPE category of the current locale at run time is the same as the LC_CTYPE category of the current locale at compile time. This is because the wchar_t representation is plat‐ form- and locale-dependent. (The glibc represents wide characters using their Unicode (ISO-10646) code point, but other platforms don't do this.