From df2ec5d7bff6adf2d1dd044278e3deb9c0e12bb2 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Wed, 1 Jul 2009 09:05:01 +0200 Subject: efa: efa.vrr.de changed something, fixed the resulting encoding fuckup Note that the arguments to efa are not recoded, so don't use unicode there --- bin/efa | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'bin/efa') diff --git a/bin/efa b/bin/efa index c704987..5904995 100755 --- a/bin/efa +++ b/bin/efa @@ -4,7 +4,7 @@ use strict; use warnings; use 5.010; -use encoding 'utf8'; +use Encode; use Getopt::Long; use WWW::Mechanize; @@ -77,7 +77,7 @@ sub parse_content($) { splice(@{$raw->[$offer]}, $offset+7, 0, ''); } for my $j (0, 4, 8) { - until (not exists($raw->[$offer]->[$offset+$j]) or $raw->[$offer]->[$offset+$j] =~ /^(\d+:\d+|ab |)$/) { + until (not exists($raw->[$offer]->[$offset+$j]) or $raw->[$offer]->[$offset+$j] =~ /^(\d+:\d+|ab |)$/) { last unless (exists($raw->[$offer]->[$offset+$j])); last if ($raw->[$offer]->[$offset+$j] eq 'Verspätungen sind berücksichtigt'); if ($raw->[$offer]->[$offset+$j] =~ /^\s*$/) { @@ -107,8 +107,7 @@ sub prepare_content($) { my $html = shift; my $offer = 0; my $return; - # beware of the no-break space (U+00A0) ↓ ↓ - foreach (split(/ \d+\. Fahrt<\/span>/, $html)) { + foreach (split(/ \d+\. Fahrt<\/span>/, $html)) { unless ($offer) { $offer++; next; @@ -267,7 +266,8 @@ $www->submit_form( fields => \%post, ); $content = $www->content; - +$content =~ s/\xa0/ /gs; +$content = encode('utf-8', decode('iso-8859-1', $content)); if (check_ambiguous($content)) { exit(1); -- cgit v1.2.3