Commit 01a95d28dde792e942201cb26a34ba7daf8afa92
1 parent
d4da0378
Exemple de gestion des accents.
Showing
2 changed files
with
23 additions
and
0 deletions
Show diff stats
... | ... | @@ -0,0 +1,22 @@ |
1 | +#include <stdio.h> | |
2 | +#include <wchar.h> // library for wide-chars | |
3 | +#include <locale.h> | |
4 | + | |
5 | +int main() { | |
6 | + wchar_t c; | |
7 | + | |
8 | + FILE* f=fopen("accents.txt", "r"); | |
9 | + setlocale(LC_ALL,""); // tell stdlib to convert chars to 4 bytes | |
10 | + | |
11 | + // Most stdio functions have wide-char counterparts | |
12 | + // Try searching "wchar wiki" for info (I could not find a proper man page) | |
13 | + while((c=fgetwc(f))!=WEOF) { | |
14 | + putwchar(c); | |
15 | + } | |
16 | + | |
17 | + // use L for wchar constants/strings | |
18 | + // also, specifier for wchar in format string is %lc | |
19 | + wprintf(L"\nAh à h%lc\n",L'â'); | |
20 | + | |
21 | + return 0; | |
22 | +} | ... | ... |
... | ... | @@ -0,0 +1 @@ |
1 | +Salut uéé, y ê tu ? | ... | ... |