Blame view

accents.c 549 Bytes
01a95d28   forget   Exemple de gestio...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
  #include <stdio.h>
  #include <wchar.h> // library for wide-chars
  #include <locale.h>
  
  int main() {
    wchar_t c;
  
    FILE* f=fopen("accents.txt", "r");
    setlocale(LC_ALL,""); // tell stdlib to convert chars to 4 bytes
  
    // Most stdio functions have wide-char counterparts
    // Try searching "wchar wiki" for info (I could not find a proper man page)
    while((c=fgetwc(f))!=WEOF) {
      putwchar(c);
    }
  
    // use L for wchar constants/strings
    // also, specifier for wchar in format string is %lc
    wprintf(L"\nAh à h%lc\n",L'â');
    
    return 0;
  }