Commit 685eb26fd3ad19083048ef762ceb68887cfa6681
1 parent
76ac53a3
ProjAccentV1.0
Showing
5 changed files
with
168 additions
and
8 deletions
Show diff stats
dico.txt
projetfinal.c
... | ... | @@ -57,7 +57,8 @@ void remplir_dico(FILE* fd, struct node tab_arbre_prcp[]) { |
57 | 57 | int cptmot = 0; |
58 | 58 | char motLu[50]; |
59 | 59 | while(fscanf(fd, "%s", motLu)==1) { |
60 | - int charEstUneLettre = 1; | |
60 | + printf("mot lu : %s\n", motLu); | |
61 | + int estUneLettre = 1; | |
61 | 62 | int i = 0; |
62 | 63 | cptmot += 1; |
63 | 64 | if((motLu[0] >= 'A') && (motLu[0] <= 'Z')) { |
... | ... | @@ -69,10 +70,11 @@ void remplir_dico(FILE* fd, struct node tab_arbre_prcp[]) { |
69 | 70 | else { |
70 | 71 | printf("Erreur remplissage dico : L'un des caracteres n'est pas une lettre\n"); |
71 | 72 | printf("Mot : %s incorrect\n", motLu); |
72 | - charEstUneLettre = 0; | |
73 | + estUneLettre = 0; | |
73 | 74 | } |
74 | - while((motLu[i] != '\0') && (charEstUneLettre == 1)) { | |
75 | + while((motLu[i] != '\0') && (estUneLettre == 1)) { | |
75 | 76 | i += 1; |
77 | + printf("lettre lue %d\n", motLu[i]); | |
76 | 78 | localisationArbre = insertion(motLu[i], localisationArbre); |
77 | 79 | } |
78 | 80 | } |
... | ... | @@ -142,6 +144,7 @@ void correction_mot(struct node tab_arbre_prcp[]) { |
142 | 144 | } |
143 | 145 | while((verif == 1) && (motLu[i] != '\0')) { |
144 | 146 | i += 1; |
147 | + printf("lettre lue %d\n", motLu[i]); | |
145 | 148 | localisationArbre = test_mot(motLu[i], localisationArbre, &verif); |
146 | 149 | } |
147 | 150 | if(verif == 0) printf("Mot : %s non present dans le dicitonnaire.\n", motLu); | ... | ... |
projetfinal.exe
No preview for this file type
projetfinalwchar_t.c
1 | 1 | #include <stdio.h> |
2 | 2 | #include <stdlib.h> |
3 | -#include <wchar.h> | |
3 | +#include <stddef.h> | |
4 | 4 | #include <locale.h> |
5 | 5 | |
6 | 6 | #define A 26 |
... | ... | @@ -52,6 +52,157 @@ struct cell ** insertion(wchar_t elem, struct cell** pL) { |
52 | 52 | } |
53 | 53 | } |
54 | 54 | |
55 | +wchar_t conversion_accent(wchar_t lettre) { // Conversion Unicode -> ASCII 256 | |
56 | + switch(lettre) { | |
57 | + case 192 : //À | |
58 | + lettre = 182; | |
59 | + break; | |
60 | + case 193 : //Á | |
61 | + lettre = 181; | |
62 | + break; | |
63 | + case 194 : //Â | |
64 | + lettre = 182; | |
65 | + break; | |
66 | + case 198 : //Æ | |
67 | + lettre = 146; | |
68 | + break; | |
69 | + case 199 : //Ç | |
70 | + lettre = 128; | |
71 | + break; | |
72 | + case 200 : //È | |
73 | + lettre = 212; | |
74 | + break; | |
75 | + case 201 : //É | |
76 | + lettre = 144; | |
77 | + break; | |
78 | + case 202 : //Ê | |
79 | + lettre = 210; | |
80 | + break; | |
81 | + case 203 : //Ë | |
82 | + lettre = 211; | |
83 | + break; | |
84 | + case 204 : //Ì | |
85 | + lettre = 141; | |
86 | + break; | |
87 | + case 205 : //Í | |
88 | + lettre = 214; | |
89 | + break; | |
90 | + case 206 : //Î | |
91 | + lettre = 215; | |
92 | + break; | |
93 | + case 207 : //Ï | |
94 | + lettre = 216; | |
95 | + break; | |
96 | + case 209 : //Ñ | |
97 | + lettre = 165; | |
98 | + break; | |
99 | + case 210 : //Ò | |
100 | + lettre = 227; | |
101 | + break; | |
102 | + case 211 : //Ó | |
103 | + lettre = 224; | |
104 | + break; | |
105 | + case 212 : //Ô | |
106 | + lettre = 226; | |
107 | + break; | |
108 | + /* case 140 : //Œ | |
109 | + lettre = | |
110 | + break;*/ | |
111 | + case 217 : //Ù | |
112 | + lettre = 235; | |
113 | + break; | |
114 | + case 218 : //Ú | |
115 | + lettre = 233; | |
116 | + break; | |
117 | + case 219 : //Û | |
118 | + lettre = 234; | |
119 | + break; | |
120 | + case 220 : //Ü | |
121 | + lettre = 154; | |
122 | + break; | |
123 | + case 221 : //Ý | |
124 | + lettre = 237; | |
125 | + break; | |
126 | + /*case 159 : //Ÿ | |
127 | + lettre = | |
128 | + break;*/ | |
129 | + case 224 : //à | |
130 | + lettre = 233; | |
131 | + break; | |
132 | + case 225 : //á | |
133 | + lettre = 160; | |
134 | + break; | |
135 | + case 226 : //â | |
136 | + lettre = 131; | |
137 | + break; | |
138 | + case 230 : //æ | |
139 | + lettre = 145; | |
140 | + break; | |
141 | + case 231 : //ç | |
142 | + lettre = 135; | |
143 | + break; | |
144 | + case 232 : //è | |
145 | + lettre = 138; | |
146 | + break; | |
147 | + case 233 : //é | |
148 | + lettre = 130; | |
149 | + break; | |
150 | + case 234 : //ê | |
151 | + lettre = 136; | |
152 | + break; | |
153 | + case 235 : //ë | |
154 | + lettre = 137; | |
155 | + break; | |
156 | + case 236 : //ì | |
157 | + lettre = 141; | |
158 | + break; | |
159 | + case 237 : //í | |
160 | + lettre = 161; | |
161 | + break; | |
162 | + case 238 : //î | |
163 | + lettre = 140; | |
164 | + break; | |
165 | + case 239 : //ï | |
166 | + lettre = 139; | |
167 | + break; | |
168 | + case 241 : //ñ | |
169 | + lettre = 164; | |
170 | + break; | |
171 | + case 242 : //ò | |
172 | + lettre = 149; | |
173 | + break; | |
174 | + case 243 : //ó | |
175 | + lettre = 162; | |
176 | + break; | |
177 | + case 244 : //ô | |
178 | + lettre = 147; | |
179 | + break; | |
180 | + /*case 156 : //œ | |
181 | + lettre = | |
182 | + break;*/ | |
183 | + case 249 : //ù | |
184 | + lettre = 151; | |
185 | + break; | |
186 | + case 250 : //ú | |
187 | + lettre = 163; | |
188 | + break; | |
189 | + case 251 : //û | |
190 | + lettre = 150; | |
191 | + break; | |
192 | + /*case 252 : //ü | |
193 | + lettre = | |
194 | + break;*/ | |
195 | + case 253 : //ý | |
196 | + lettre = 263; | |
197 | + break; | |
198 | + case 255 : //ÿ | |
199 | + lettre = 152; | |
200 | + break; | |
201 | + default : | |
202 | + break; | |
203 | + } | |
204 | + return lettre; | |
205 | +} | |
55 | 206 | |
56 | 207 | void remplir_dico(FILE* fd, struct node tab_arbre_prcp[]) { |
57 | 208 | |
... | ... | @@ -77,8 +228,11 @@ void remplir_dico(FILE* fd, struct node tab_arbre_prcp[]) { |
77 | 228 | while((motLu[i] != '\0') && (wchar_tEstUneLettre == 1)) { |
78 | 229 | i += 1; |
79 | 230 | wprintf(L"lettre lue %ld\n", motLu[i]); |
231 | + if(motLu[i] > 127) {motLu[i] = conversion_accent(motLu[i]); | |
232 | + wprintf(L"lettre lue apres convversion : %ld\n", motLu[i]);} | |
80 | 233 | localisationArbre = insertion(motLu[i], localisationArbre); |
81 | 234 | } |
235 | + wprintf(L"mot lu 2: %ls\n", motLu); | |
82 | 236 | } |
83 | 237 | wprintf(L"\n"); |
84 | 238 | fclose(fd); |
... | ... | @@ -104,6 +258,7 @@ void correction_txt(FILE* fd, struct node tab_arbre_prcp[]) { |
104 | 258 | int verif; |
105 | 259 | wchar_t motLu[50]; |
106 | 260 | while(fwscanf(fd, L"%ls", motLu)==1) { |
261 | + wprintf(L"mot lu : %ls\n", motLu); | |
107 | 262 | verif = 1; |
108 | 263 | int i = 0; |
109 | 264 | if((motLu[0] >= 'A') && (motLu[0] <= 'Z')) { |
... | ... | @@ -117,13 +272,15 @@ void correction_txt(FILE* fd, struct node tab_arbre_prcp[]) { |
117 | 272 | verif = 0; |
118 | 273 | } |
119 | 274 | while((verif == 1) && (motLu[i] != '\0')) { |
120 | - wprintf(L"mot lu : %ls\n", motLu); | |
121 | 275 | i += 1; |
276 | + if(motLu[i] > 127) {motLu[i] = conversion_accent(motLu[i]); | |
277 | + wprintf(L"mot lu 2 : %ls\n", motLu);} | |
122 | 278 | localisationArbre = test_mot(motLu[i], localisationArbre, &verif); |
123 | 279 | wprintf(L"lettre lue %ld\n", motLu[i]); |
124 | 280 | } |
125 | 281 | wprintf(L"\n"); |
126 | 282 | if(verif == 0) wprintf(L"Mot %ls non present dans le dicitonnaire.\n", motLu); |
283 | + | |
127 | 284 | } |
128 | 285 | fclose(fd); |
129 | 286 | } |
... | ... | @@ -144,7 +301,7 @@ void correction_mot(struct node tab_arbre_prcp[]) { |
144 | 301 | localisationArbre = &tab_arbre_prcp[motLu[0]-97].listeFils; |
145 | 302 | } |
146 | 303 | else { |
147 | - wprintf(L"Erreur correction txt : L'un des caract%lcres n'est pas une lettre\n", 130); | |
304 | + wprintf(L"Erreur correction mot : L'un des caract%lcres n'est pas une lettre\n", 130); | |
148 | 305 | verif = 0; |
149 | 306 | } |
150 | 307 | while((verif == 1) && (motLu[i] != '\0')) { |
... | ... | @@ -159,7 +316,6 @@ void correction_mot(struct node tab_arbre_prcp[]) { |
159 | 316 | |
160 | 317 | |
161 | 318 | int main(int argc, char* argv[]) { |
162 | - | |
163 | 319 | FILE* dico = NULL; |
164 | 320 | FILE* txt = NULL; |
165 | 321 | struct node tab_arbre[A]; | ... | ... |
projetfinalwchar_t.exe
No preview for this file type