using characters å ä ö

 
Post new topic   Reply to topic    Aprelium Forum Index -> Perl
View previous topic :: View next topic  
Author Message
netro
-


Joined: 09 Aug 2003
Posts: 8

PostPosted: Fri Aug 22, 2003 12:36 am    Post subject: using characters å ä ö Reply with quote

when i try to use characters å ä and ö in my script:#!/usr/bin/perl
print "Content-type:text/html\n\n";
use CGI::Carp qw(fatalsToBrowser);

read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/\n/ /g; # replace newlines with spaces
$value =~ s/\r//g; # remove hard returns
$value =~ s/\cM//g; # delete ^M's
$FORM{$name} = $value;
}

open(OUTF,">c:/$FORM{'name'}.html") or dienice("Couldn't open survey.out for writing: $!");

if ($FORM{'howreach'} = 1) {
$FORM{'howreach'}=Komedi;
} elsif ($FORM{'howreach'} = 2) {
$FORM{'howreach'}=Action;
} elsif ($FORM{'howreach'} = 3) {
$FORM{'howreach'}=Skräck;
} elsif ($FORM{'howreach'} = 4) {
$FORM{'howreach'}=Drama;
} elsif ($FORM{'howreach'} = 2) {
$FORM{'howreach'}=Thriller;
}else {
$FORM{'howreach'}=Annat;
}


print OUTF "$FORM{'name'}<br>$FORM{'email'}<br>";
print OUTF "$FORM{'howreach'}<br>$FORM{'rating'}<br>";

%boxes = ( "des" => "Website Design",
"svr" => "Web Server Administration",
"com" => "Electronic Commerce",
"mkt" => "Web Marketing/Advertising",
"edu" => "Web-Related Education" );

foreach $key (keys %boxes) {
if ($FORM{$key} == 1) {
print OUTF "$key,";
}
}

print OUTF "<br>$FORM{'comments'}\n";
close(OUTF);

print <<EndHTML;
<html><head><title>johhanes helvete</title></head>
<body>
<h2>Hallå Thomas</h2>
Nu är det klart.<p>
<a href="http://localhost/index1.html">tillbaka till huvudsidan</a><p>
</body></html>
EndHTML

sub dienice {
my($msg) = @_;
print "<h2>Error</h2>\n";
print $msg;
exit;
}

i get an error saying:Unrecognized character \xE4 at hell.cgi line 24.

what can i do? :cry:
Back to top View user's profile Send private message
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Fri Aug 22, 2003 12:13 pm    Post subject: Re: using characters å ä ö Reply with quote

The problem is with your Perl code and especially with the lines that are similar to:
Code:
$FORM{'howreach'}=Komedi;

Such a line should be written as:
Code:
$FORM{'howreach'}="Komedi";

since Komedi is not a name of a function. It is just a string.
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> Perl All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group