Commit 284154cafeed848e011db89d8aadae10eb748abe

Authored by Thorsieger
1 parent 34d66d1d

gestion des accents

Showing 6 changed files with 22 additions and 17 deletions   Show diff stats
dico_test
... ... @@ -3,4 +3,5 @@ ba
3 3 aa'
4 4 abc
5 5 c
6   -d'
7 6 \ No newline at end of file
  7 +d'
  8 +aé
8 9 \ No newline at end of file
... ...
1 1 #include "find.h"
2 2  
3 3  
4   -int find_mot(struct node **tab_ptr_tree,char mot[],int size,int fl)
  4 +int find_mot(struct node **tab_ptr_tree,wchar_t mot[],int size,int fl)
5 5 {
6 6 if(size==1 && tab_ptr_tree[fl]!=NULL)
7 7 {
... ...
... ... @@ -2,4 +2,4 @@
2 2  
3 3 int find();
4 4  
5   -int find_mot(struct node **,char*,int,int);
6 5 \ No newline at end of file
  6 +int find_mot(struct node **,wchar_t*,int,int);
7 7 \ No newline at end of file
... ...
... ... @@ -2,8 +2,9 @@
2 2  
3 3 int main()
4 4 {
5   - FILE* fp = fopen("american-english","r");
6   - //FILE* fp = fopen("dico_test","r");
  5 + setlocale(LC_ALL, "");
  6 + //FILE* fp = fopen("american-english","r");
  7 + FILE* fp = fopen("dico_test","r");
7 8  
8 9 if(fp == NULL) return 1 ; //File is not readable
9 10  
... ... @@ -18,11 +19,11 @@ int main()
18 19  
19 20 printf("Loading done!\n");
20 21  
21   - char mot[50];
  22 + wchar_t mot[50];
22 23 int taille;
23 24 taille = 8;
24   - scanf("%s",mot);
25   - scanf("%d",&taille);
  25 + wscanf(L"%ls",mot);
  26 + wscanf(L"%d",&taille);
26 27 int result;
27 28 result = find_mot(tab,mot,taille,0);
28 29 printf("%d\n",result);
... ...
1 1 #include "tree.h"
2 2  
3   -void cons_tree(struct node ** ptr_tree, int val)
  3 +void cons_tree(struct node ** ptr_tree, wchar_t val)
4 4 {
5 5 *ptr_tree = malloc(sizeof(struct node));
6 6 (*ptr_tree)->val = val;
... ... @@ -20,7 +20,7 @@ int is_leaf(struct node *tree)
20 20 return tree->fin||tree->fils[0]==NULL;
21 21 }
22 22  
23   -void add(struct node **tab_ptr_tree, char val[],int taille, int fl)
  23 +void add(struct node **tab_ptr_tree, wchar_t val[],int taille, int fl)
24 24 {
25 25 if(tab_ptr_tree[fl]==NULL)cons_tree(&(tab_ptr_tree[fl]),val[0]+97);
26 26 Node* noeudtest = tab_ptr_tree[fl];
... ... @@ -46,7 +46,7 @@ void add(struct node **tab_ptr_tree, char val[],int taille, int fl)
46 46  
47 47 }
48 48  
49   -int size(char val[])
  49 +int size(wchar_t val[])
50 50 {
51 51 int cpt = 0;
52 52 while(val[cpt]!='\0')
... ... @@ -56,7 +56,7 @@ int size(char val[])
56 56 return cpt;
57 57 }
58 58  
59   -void toLowerCase(char mot[],int size)
  59 +void toLowerCase(wchar_t mot[],int size)
60 60 {
61 61 for(int i=0;i<size;i++)
62 62 {
... ... @@ -71,12 +71,13 @@ void toLowerCase(char mot[],int size)
71 71 void load_tree(FILE *fp, struct node **tab_ptr_tree)
72 72 {
73 73 //fl (first letter)
74   - char val[50];
  74 + wchar_t val[50];
75 75  
76   - while(fscanf(fp, "%s",val)==1)
  76 + while(fwscanf(fp, L"%ls",val)==1)
77 77 {
78 78 int taille = size(val);
79 79 toLowerCase(val,taille);
  80 + if(val[0]<'a' || val[0]>'z')continue;
80 81 //if(val[0]<97)val[0]+=32;
81 82 //val[0]-=97;
82 83 add(tab_ptr_tree,val,taille,(int)val[0]-97);
... ...
1 1 #include <stdio.h>
2 2 #include <stdlib.h>
  3 +#include <wchar.h>
  4 +#include <locale.h>
3 5  
4 6 typedef struct node {
5   - int val;
  7 + wchar_t val;
6 8 int fin;
7 9 int nbr_fils;
8 10 struct node** fils;
9 11 }Node, *PtNode, *Tree;
10 12  
11   -void cons_tree(struct node **, int);
  13 +void cons_tree(struct node **, wchar_t);
12 14  
13 15 void mk_empty_tree(struct node **);
14 16  
15 17 int is_leaf(struct node *);
16 18  
17   -void add(struct node **, char* ,int ,int);
  19 +void add(struct node **, wchar_t* ,int ,int);
18 20  
19 21 void load_tree(FILE *, struct node **);
20 22  
... ...