Gossamer Forum
Quote Reply
Convert accents to html
Hi,

I've just dug up some code I used in a perl script I had written. Got the idea from an OReilly book.

The idea is to modify data that will be displayed in order for it to be HTML compliant and hence compatible with most browsers. Some seem to be able to display for example the word summer in French correctly when I type "été" others (older ones) seem to need it to be written été

This is the code I used in my perl script :

$description = &conversion_html ($description);

and this is the sub routine :

########################## Accents html conversion

conversion_html {local ($chaine) = @_;local (%signes_html, $chaine_html);

%caracteres_html =
(
'à', 'à',
'â', 'â',
'é', 'é',
'è', 'è',
'ê', 'ê',
'î', 'î',
'ô', 'ô',
'ù', 'ù',
'û', 'û',
'ç', 'ç',);

$chaine_html =
join ("", keys %caracteres_html);$chaine =~ s/([$chaine_html])/$caracteres_html{$1}/go;return ($chaine);

##########################

As you can see this would also work to provide the correct codes if modified for most european languages.

I was trying to create a sub for it so that I could let my editors simply type in with accents their reviews and then this would convert to html compliant code.

But this was written years ago and I'm not really sure what to do about creating a sub. I've tried and failed miserably with 500 errors each time. If anybody has any ideas I'm sure this could be useful to others aswell...

Thanks, John
Significant Media
Subject Author Views Date
Thread Convert accents to html Jag 2257 Sep 17, 2004, 9:26 PM
Thread Re: [Jag] Convert accents to html
webmaster33 2172 Sep 18, 2004, 3:56 AM
Thread Re: [webmaster33] Convert accents to html
Jag 2169 Sep 18, 2004, 12:17 PM
Post Re: [Jag] Convert accents to html
webmaster33 2167 Sep 18, 2004, 12:38 PM
Post Re: [Jag] Convert accents to html
webmaster33 2175 Sep 18, 2004, 12:51 PM