This was quite interesting. Apparently the compiler translates the omega from UTF-8 to UNICODE but somehow the libc messes it up.
First of all: the %c
-format specifier expects a char
(even in the wprintf-version) so you have to specify %lc
(and therefore %ls
for strings).
Secondly if you run your code like that the locale is set to C
(it isn't automatically taken from the environment). You have to call setlocale
with an empty string to take the locale from the environment, so the libc is happy again.
#include <stdio.h>
#include <wchar.h>
#include <stdlib.h>
#include <locale.h>
int main() {
int r;
wchar_t myChar1 = L'Ω';
setlocale(LC_CTYPE, "");
r = wprintf(L"char is %lc (%x)\n", myChar1, myChar1);
}