Wide character in subroutine entry at D:/meinpfad/test_charset1.pl line 21
2014-07-09T18:15:38 rostidass für IO grundsätzlich eine byte-semantic vorliegen muss.
2014-07-09T18:15:38 rostiFalls möglich, setze den IO-Layer auf die Kodierung Deiner Zeichenkette oder nutze das Pragma use bytes;
1 2 3 4 5 6 7 8 9 10
use utf8; my $s = 'äöüß'; say length $s; # 4 use bytes; say length $s; # 8 no bytes; say length $s; # 4
2014-07-10T09:12:48 rostiMit
wird $s zu einer UTF-8-kodierten Zeichenkette (String)
1 2
my $content = $response->decoded_content; my $ref = JSON->new->utf8->decode($content);
Quotedecode_json
$perl_scalar = decode_json $json_text
The opposite of "encode_json": expects an UTF-8 (binary) string and tries to parse that as an UTF-8 encoded JSON text, returning the
resulting reference.
This function call is functionally identical to:
$perl_scalar = JSON->new->utf8->decode($json_text)
Quote$r->decoded_content( %options )
This will return the content after any "Content-Encoding" and charsets have been decoded. See HTTP::Message for details.
2014-07-09T18:40:32 RaubtierDu darfst JSON also nicht von utf8-binary konvertieren lassen. Sollte also wohl my $ref = JSON->new->utf8(0)->decode($content); heißen.
QuoteUse of uninitialized value $out in concatenation (.) or string at test_charset1.pl line 27
1 2
my $converter = Text::Iconv->new('UTF-8','ISO-8859-15'); $out = $converter->convert($out);
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
#!/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').<<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 ;
1
2
3
4
5
6
7
8
####################
Zeile 24
{"1":"\"öäüÖÄÜ€@ß\"","2":"\"öäüÖÄÜ@€ß\""}
####################
Zeile 29
"öäüÖÄÜ€@ß""öäüÖÄÜ@€ß"
####################
Zeile 32
1 2 3 4
#my $converter = Text::Iconv->new('UTF-8','ISO-8859-15'); #$out = $converter->convert($out); $out = encode('ISO-8859-15',$out); say $f ('#'x20)."\nZeile ".__LINE__."\n$out";
1
2
3
4
5
6
7
8
9
####################
Zeile 25
{"1":"\"öäüÖÄÜ€@ß\"","2":"\"öäüÖÄÜ@€ß\""}
####################
Zeile 30
"öäüÖÄÜ€@ß""öäüÖÄÜ@€ß"
####################
Zeile 34
"ö__ÖÄÜ€@ß""ö__ÖÄÜ@€ß"
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 ;