1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
##!/usr/bin/perl use strict; use warnings; use utf8; use Data::Dumper; use CGI; use Encode qw( encode decode ); my $File = "/var/www/htdocs/DumperFile.dat"; my $query = new CGI(); print $query->header(-type=>'text/html', -charset=>'utf-8'); my @names = $query->param; my $queryParams = ""; my $savedDumpFile = writeFile(@names); printOutput(@names); exit; sub printOutput { my @names = @_; my $queryParams = ""; print "saved mairlist dumper-file: ".$File."\n" if ($savedDumpFile == 1); for my $name ( @names ) { if ( $name =~ /\_/ ) { next; } else { $queryParams .= $name."\t\t".$query->param($name)."\n"; } } my $utf8 = $queryParams; print Dumper($utf8)."\n"; return 1; } sub writeFile { my @names = @_; my $queryParams = ""; open(FILE, ">>$File") || die ("Could not open file"); for my $name ( @names ) { if ( $name =~ /\_/ ) { next; } else { $queryParams .= $name."\t\t".$query->param($name)."\n"; } } print FILE Dumper($queryParams)."\n"; close( FILE ) || die("Could not close file"); return 1; } # EOF
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
$VAR1 = 'action start
artist HP
filePath D:/some/path/HP - Früher War Alles Besser [Dezember 2013]/HP - (Früher War Alles Besser 01).mp3
timestampStart 2016-12-03 01:49:10
title Früher War Alles Besser 01 öäüß
type Promo
totalTime 00:00:31
';
$VAR1 = 'action stop
artist Lady Antebellum
filePath D:/some/path/Lady Antebellum - All I Want For Christmas Is You -- 2012.mp3
timestampStart 2016-12-03 01:49:12
title All I Want For Christmas Is You -- 2012
type Music
totalTime 00:03:35
';
[error]Caught exception in engine "utf8 "\xF6" does not map to Unicode at /usr/local/share/perl/5.20.2/Catalyst.pm line 3662."
2016-12-04T16:22:58 cbxk1xg@Janus: Ich weiss doch welche Codierung ich bekomme: Latin-1
Es geht darum, wie ich Catalyst dazu bewege, damit umzugehen.
2016-12-05T12:29:04 cbxk1xgJa. Aber daher ja meine Frage: Wo kann ich das ändern. Denn in der Doku steht dazu nichts passendes. Wenn sich Catalyst immer so verhält, nur weil ein Request eine Exception wirft, ist es eh unbrauchbar.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
sub decodeRequestParams { my ($self, $c) = @_; my @params = $c->request->param; my %requestParams = (); my $ua = Parse::HTTP::UserAgent->new( $c->request->user_agent ); for my $key (@params) { if ($ua =~ m/MyBadBadKitty/i) { $requestParams{$key} = decode("iso-8859-1", $c->request->param($key)); } else {$requestParams{$key} = $c->request->param($key);} } return (%requestParams); }