Commit 0e453bf3cd07703b9bbea59289f9456274616308

Authored by rsSimonin
2 parents 6ab96f9e f6189412

Merge https://archives.plil.fr/wrudamet2/ima3_projet_pa_2019

Showing 3 changed files with 29 additions and 0 deletions   Show diff stats
accents.c 0 → 100644
... ... @@ -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 +}
... ...
accents.txt 0 → 100644
... ... @@ -0,0 +1 @@
  1 +Salut uéé, y ê tu ?
... ...
conv-accents.sh 0 → 100755
... ... @@ -0,0 +1,6 @@
  1 +#!/bin/bash
  2 +
  3 +if [ $# -ne 1 ]
  4 +then echo "Usage: $0 /usr/share/dict/your_language (creates a local copy with accents converted)"
  5 +else iconv -f utf8 -t ascii//TRANSLIT $1 > `basename $1`-no-accents
  6 +fi
... ...