Thread Hilfe bei charset und use utf8 (10 answers)
Opened by bianca at 2014-07-09 19:10

bianca
 2014-07-10 10:56
#176365 #176365
User since
2009-09-13
6991 Artikel
BenutzerIn

user image
So gehts:
Code (perl): (dl )
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
#!/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 Data::Dumper;
use 5.010;
use Encode qw(encode);
# dieses Script wird in Notepad++ als "ANSI" gespeichert

open(my $f,">test_charset_debug.txt");
my $test = POST(
    'http://www.meinlokalerserver.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->decode($content);
my %test = %$ref;
my $out = '';
foreach my $k (keys %test) { $out .= $test{$k} }
say $f ('#'x20)."\nZeile ".__LINE__."\n$out";
$out = encode('ISO-8859-15',$out);
say $f ('#'x20)."\nZeile ".__LINE__."\n$out";
print STDOUT CGI->new->header(-charset=>'ISO-8859-15').<<HTML_TEIL
<doctype html>
<html>
<head>
    <meta http-equiv="content-type" content="text/html;charset=ISO-8859-15">
</head>
<body>
<pre>$out</pre>
</body>
</html>
HTML_TEIL
;


Danke euch!
10 print "Hallo"
20 goto 10

View full thread Hilfe bei charset und use utf8