Thread Unicode, WWW::Mechanize und Unicode::String (3 answers)
Opened by J-jayz-Z at 2006-10-06 13:45

ptk
 2006-10-07 19:27
#70565 #70565
User since
2003-11-28
3645 Artikel
ModeratorIn
[default_avatar]
Ich konnte das Problem nicht reproduzieren. Als Testdatei habe ich folgendes verwendet (wobei die Umlaute in iso-8859-1 enkodiert sind):
Code: (dl )
1
2
3
4
5
6
7
8
<html>
<head>
<title>Test iso-8859-1</title>
</head>
<body>
Hallo äöüß
</body>
</html>

Der Apache fügt von sich aus keine Content-Type-Header hinzu:
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
$ lwp-request -m HEAD http://www/~eserte/test/enc-iso88591.html
200 OK
Connection: close
Date: Sat, 07 Oct 2006 15:24:28 GMT
Accept-Ranges: bytes
ETag: "fed8eb-5f-4527c67e"
Server: Apache/1.3.34 (Unix) mod_perl/1.29
Content-Length: 95
Content-Type: text/html
Last-Modified: Sat, 07 Oct 2006 15:23:42 GMT
Client-Date: Sat, 07 Oct 2006 15:24:28 GMT
Client-Peer: 192.168.1.5:80
Client-Response-Num: 1

Mit einem minimalen WWW-Mechanize-Skript kommt nicht Überraschendes heraus:
Code: (dl )
1
2
3
4
use WWW::Mechanize;
my $ua = WWW::Mechanize->new;
my $resp = $ua->get("http://www/~eserte/test/enc-iso88591.html");
use Devel::Peek; Dump $resp->content;

Das Ergebnis:
Code: (dl )
1
2
3
4
5
6
SV = PV(0x82166b0) at 0x82e75c8
REFCNT = 1
FLAGS = (TEMP,POK,pPOK)
PV = 0x83f4518 "<html>\n <head>\n <title>Test iso-8859-1</title>\n </head>\n <body>\n Hallo \344\366\374\337\n </body>\n</html>\n"\0
CUR = 95
LEN = 96

Also weiterhin alles in iso-8859-1. Und auch wenn ein UTF8-Flag hier vorkommen würde, dann hättest du mit Encode::encode dein gewünschtes Ergebnis bekommen.

View full thread Unicode, WWW::Mechanize und Unicode::String