#!/usr/bin/perl -w
$|++;
use Text::Aspell;
use CGI qw/:standard/;
use locale;
use Unicode::String;


print header; 


my $word = param('phrase');
#CFprint "Word: $word<br />";

$word =~ s/\%([0-9a-f]{2})/chr(hex($1))/egi;


#$word = Unicode::String::utf8($word)->latin1;


my $speller = Text::Aspell->new;
$speller->set_option('lang','fr_FR');
$speller->set_option('sug-mode','fast');

#print join("<br />", $speller->list_dictionaries);


my @checkit = ();

my $current_word="";
foreach(split ' ',$word)
{
my $real = $_;
#s/[^\w摳僸鳹臅瀀譐咤𥌓ぶ//g;
#print "CHECK $_<br />\n";
if ($speller->check($_))
{
push(@checkit,$real);
}

else { push(@checkit,"<span class=\"bad\">$real</span>"); }
}
print join(" ",@checkit);




#print "FIN\n";
