printf
just sends raw bytes to your terminal; it does not know anything about encodings. If your terminal happens to be configured to interpret that as UTF-8, it will show the right characters.
wprintf
, on the other hand, does know about encodings. It behaves as though it uses the function wcrtomb, which encodes a wide character (wchar_t
) into a multibyte sequence, depending on the current locale. If the default locale happens to be "C"
, which is quite minimalistic, the character æ
gets converted to the "more or less equivalent" byte sequence ae
.
If you set the locale explicitly to something using UTF-8, like "en_US.UTF-8"
, the output is as expected. Of course, the set of supported locales differs per system, so it's no good to hardcode this.