From 685eb26fd3ad19083048ef762ceb68887cfa6681 Mon Sep 17 00:00:00 2001 From: tvieuble Date: Wed, 17 Apr 2019 19:44:30 +0200 Subject: [PATCH] ProjAccentV1.0 --- dico.txt | 3 ++- projetfinal.c | 9 ++++++--- projetfinal.exe | Bin 136468 -> 0 bytes projetfinalwchar_t.c | 164 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---- projetfinalwchar_t.exe | Bin 137167 -> 0 bytes 5 files changed, 168 insertions(+), 8 deletions(-) diff --git a/dico.txt b/dico.txt index ae635f9..37b3b87 100644 --- a/dico.txt +++ b/dico.txt @@ -2,4 +2,5 @@ tl pche vtre pche -abricot \ No newline at end of file +abricot +l'arbre \ No newline at end of file diff --git a/projetfinal.c b/projetfinal.c index 7291028..64b5786 100644 --- a/projetfinal.c +++ b/projetfinal.c @@ -57,7 +57,8 @@ void remplir_dico(FILE* fd, struct node tab_arbre_prcp[]) { int cptmot = 0; char motLu[50]; while(fscanf(fd, "%s", motLu)==1) { - int charEstUneLettre = 1; + printf("mot lu : %s\n", motLu); + int estUneLettre = 1; int i = 0; cptmot += 1; if((motLu[0] >= 'A') && (motLu[0] <= 'Z')) { @@ -69,10 +70,11 @@ void remplir_dico(FILE* fd, struct node tab_arbre_prcp[]) { else { printf("Erreur remplissage dico : L'un des caracteres n'est pas une lettre\n"); printf("Mot : %s incorrect\n", motLu); - charEstUneLettre = 0; + estUneLettre = 0; } - while((motLu[i] != '\0') && (charEstUneLettre == 1)) { + while((motLu[i] != '\0') && (estUneLettre == 1)) { i += 1; + printf("lettre lue %d\n", motLu[i]); localisationArbre = insertion(motLu[i], localisationArbre); } } @@ -142,6 +144,7 @@ void correction_mot(struct node tab_arbre_prcp[]) { } while((verif == 1) && (motLu[i] != '\0')) { i += 1; + printf("lettre lue %d\n", motLu[i]); localisationArbre = test_mot(motLu[i], localisationArbre, &verif); } if(verif == 0) printf("Mot : %s non present dans le dicitonnaire.\n", motLu); diff --git a/projetfinal.exe b/projetfinal.exe index 65b6a9e..cdc2665 100644 Binary files a/projetfinal.exe and b/projetfinal.exe differ diff --git a/projetfinalwchar_t.c b/projetfinalwchar_t.c index 97af7b5..4baf076 100644 --- a/projetfinalwchar_t.c +++ b/projetfinalwchar_t.c @@ -1,6 +1,6 @@ #include #include -#include +#include #include #define A 26 @@ -52,6 +52,157 @@ struct cell ** insertion(wchar_t elem, struct cell** pL) { } } +wchar_t conversion_accent(wchar_t lettre) { // Conversion Unicode -> ASCII 256 + switch(lettre) { + case 192 : //À + lettre = 182; + break; + case 193 : //Á + lettre = 181; + break; + case 194 : // + lettre = 182; + break; + case 198 : //Æ + lettre = 146; + break; + case 199 : //Ç + lettre = 128; + break; + case 200 : //È + lettre = 212; + break; + case 201 : //É + lettre = 144; + break; + case 202 : //Ê + lettre = 210; + break; + case 203 : //Ë + lettre = 211; + break; + case 204 : //Ì + lettre = 141; + break; + case 205 : //Í + lettre = 214; + break; + case 206 : //Î + lettre = 215; + break; + case 207 : //Ï + lettre = 216; + break; + case 209 : //Ñ + lettre = 165; + break; + case 210 : //Ò + lettre = 227; + break; + case 211 : //Ó + lettre = 224; + break; + case 212 : //Ô + lettre = 226; + break; + /* case 140 : //Œ + lettre = + break;*/ + case 217 : //Ù + lettre = 235; + break; + case 218 : //Ú + lettre = 233; + break; + case 219 : //Û + lettre = 234; + break; + case 220 : //Ü + lettre = 154; + break; + case 221 : //Ý + lettre = 237; + break; + /*case 159 : //Ÿ + lettre = + break;*/ + case 224 : //à + lettre = 233; + break; + case 225 : //á + lettre = 160; + break; + case 226 : //â + lettre = 131; + break; + case 230 : //æ + lettre = 145; + break; + case 231 : //ç + lettre = 135; + break; + case 232 : //è + lettre = 138; + break; + case 233 : //é + lettre = 130; + break; + case 234 : //ê + lettre = 136; + break; + case 235 : //ë + lettre = 137; + break; + case 236 : //ì + lettre = 141; + break; + case 237 : //í + lettre = 161; + break; + case 238 : //î + lettre = 140; + break; + case 239 : //ï + lettre = 139; + break; + case 241 : //ñ + lettre = 164; + break; + case 242 : //ò + lettre = 149; + break; + case 243 : //ó + lettre = 162; + break; + case 244 : //ô + lettre = 147; + break; + /*case 156 : //œ + lettre = + break;*/ + case 249 : //ù + lettre = 151; + break; + case 250 : //ú + lettre = 163; + break; + case 251 : //û + lettre = 150; + break; + /*case 252 : //ü + lettre = + break;*/ + case 253 : //ý + lettre = 263; + break; + case 255 : //ÿ + lettre = 152; + break; + default : + break; + } + return lettre; +} void remplir_dico(FILE* fd, struct node tab_arbre_prcp[]) { @@ -77,8 +228,11 @@ void remplir_dico(FILE* fd, struct node tab_arbre_prcp[]) { while((motLu[i] != '\0') && (wchar_tEstUneLettre == 1)) { i += 1; wprintf(L"lettre lue %ld\n", motLu[i]); + if(motLu[i] > 127) {motLu[i] = conversion_accent(motLu[i]); + wprintf(L"lettre lue apres convversion : %ld\n", motLu[i]);} localisationArbre = insertion(motLu[i], localisationArbre); } + wprintf(L"mot lu 2: %ls\n", motLu); } wprintf(L"\n"); fclose(fd); @@ -104,6 +258,7 @@ void correction_txt(FILE* fd, struct node tab_arbre_prcp[]) { int verif; wchar_t motLu[50]; while(fwscanf(fd, L"%ls", motLu)==1) { + wprintf(L"mot lu : %ls\n", motLu); verif = 1; int i = 0; if((motLu[0] >= 'A') && (motLu[0] <= 'Z')) { @@ -117,13 +272,15 @@ void correction_txt(FILE* fd, struct node tab_arbre_prcp[]) { verif = 0; } while((verif == 1) && (motLu[i] != '\0')) { - wprintf(L"mot lu : %ls\n", motLu); i += 1; + if(motLu[i] > 127) {motLu[i] = conversion_accent(motLu[i]); + wprintf(L"mot lu 2 : %ls\n", motLu);} localisationArbre = test_mot(motLu[i], localisationArbre, &verif); wprintf(L"lettre lue %ld\n", motLu[i]); } wprintf(L"\n"); if(verif == 0) wprintf(L"Mot %ls non present dans le dicitonnaire.\n", motLu); + } fclose(fd); } @@ -144,7 +301,7 @@ void correction_mot(struct node tab_arbre_prcp[]) { localisationArbre = &tab_arbre_prcp[motLu[0]-97].listeFils; } else { - wprintf(L"Erreur correction txt : L'un des caract%lcres n'est pas une lettre\n", 130); + wprintf(L"Erreur correction mot : L'un des caract%lcres n'est pas une lettre\n", 130); verif = 0; } while((verif == 1) && (motLu[i] != '\0')) { @@ -159,7 +316,6 @@ void correction_mot(struct node tab_arbre_prcp[]) { int main(int argc, char* argv[]) { - FILE* dico = NULL; FILE* txt = NULL; struct node tab_arbre[A]; diff --git a/projetfinalwchar_t.exe b/projetfinalwchar_t.exe index 96f125f..9dd2a12 100644 Binary files a/projetfinalwchar_t.exe and b/projetfinalwchar_t.exe differ -- libgit2 0.21.2