#!/usr/bin/perl -w use strict 1.04; use warnings 1.06; use CGI 3.52; use LWP::UserAgent; use HTTP::Request::Common 'POST'; use JSON 2.53; use Text::Iconv; use Data::Dumper; use 5.010; # dieses Script wird in Notepad++ als "ANSI" gespeichert open(my $f,">test_charset_debug.txt"); my $test = POST( 'http://www.lokalerserver.de/test_charset2.pl', Content_Type => 'form-data', Content => [ dummy => 'foo', ], ); my $userAgent = LWP::UserAgent->new(); my $response = $userAgent->request($test); my $content = $response->decoded_content; say $f ('#'x20)."\nZeile ".__LINE__."\n$content"; my $ref = JSON->new->utf8->decode($content); my %test = %$ref; my $out = ''; foreach my $k (keys %test) { $out .= $test{$k} } say $f ('#'x20)."\nZeile ".__LINE__."\n$out"; my $converter = Text::Iconv->new('UTF-8','ISO-8859-15'); $out = $converter->convert($out); say $f ('#'x20)."\nZeile ".__LINE__."\n$out"; print STDOUT CGI->new->header(-charset=>'ISO-8859-15').<
$out
HTML_TEIL ;