Well on my Ubuntu machine, wide characters are encoded in UTF-8 when assigned to char arrays.
Code:
$ cat foo.c
#include <stdio.h>
#include <string.h>
int main ( ) {
char buff[] = "☃";
printf("%s\n",buff);
printf("%zd\n",strlen(buff));
}
$ gcc foo.c
$ ./a.out
☃
3
$ ./a.out | hd
00000000 e2 98 83 0a 33 0a |....3.|
00000006
Whereas this does something different.
Code:
#include <stdio.h>
#include <string.h>
#include <wchar.h>
int main ( ) {
wchar_t buff[] = L"☃";
printf("%S\n",buff);
printf("%zd\n",wcslen(buff));
}
> Why printf() prints non ascii characters in a narrow-oriented stdout?
Presumably because you used a narrow char, and the compiler automatically converted it all to utf-8.
> Does it take more time to print wide characters? can it be problematic?
I/O is always relatively inefficient in time, so why worry about it.
Also, you're at the mercy of
- the quality of the std library implementation
- the extent of wide character support (either at a basic level of wide characters at all, or whether specific glyphs have been defined) in whatever terminal/console you end up using.