[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl-WebCGI] Converting Strange characters ( å , ä , ö ) in Perl/Cgi ?



>Hi,
>I wonder if thers a way to convert the swedsih characters Å, Ä, Ö, å ä ö
>into the HTML code as follows:
>  Å= Å
>  å= å
>  Ä = Ä
>  ä = ä
>  Ö = Ö
>  ö = ö
>
>I get the input from a post form and I want it to generate a Webpage but
>using the "secure" html code and not the characters itself.
>Yours sincerely
>Jimmy Lantz
>Sweden
>


Consider the following...

#!perl

  $string = <<"EOF";
Å
å
Ä
ä
Ö
ö
EOF

  %char = (
  'Ä' => '&Auml;',
  'ö' => '&ouml;',
  );


    print "BEFORE\n------\n$string\n\n";

    foreach $key (sort keys(%char)) {
	$string =~ s/$key/$char{$key}/g;
    }

    print "\nAFTER\n-----\n$string\n";

__END__


Hope this helps.

David Seay



==== Want to unsubscribe from this list?
==== Send mail with body "unsubscribe" to macperl-webcgi-request@macperl.org