From f5673f483e5ccf733fad1647a70aaed41488972f Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Wed, 5 Jul 2017 17:20:13 +0200 Subject: Fix encoding issues caused by recent API changes --- Changelog | 4 ++++ lib/Travel/Status/DE/EFA.pm | 28 ++++++++++++++-------------- t/20-vrr.t | 8 ++++---- 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/Changelog b/Changelog index 292f2b5..39444e1 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,7 @@ +git HEAD + + * Fix encoding issues caused by recent API changes + Travel::Status::DE::VRR 1.14 - Sat Oct 08 2016 * efa-m: Fix broken encoding in --list output diff --git a/lib/Travel/Status/DE/EFA.pm b/lib/Travel/Status/DE/EFA.pm index 605e92d..673313a 100644 --- a/lib/Travel/Status/DE/EFA.pm +++ b/lib/Travel/Status/DE/EFA.pm @@ -10,7 +10,7 @@ no if $] >= 5.018, warnings => 'experimental::smartmatch'; our $VERSION = '1.14'; use Carp qw(confess cluck); -use Encode qw(encode decode); +use Encode qw(encode); use Travel::Status::DE::EFA::Line; use Travel::Status::DE::EFA::Result; use Travel::Status::DE::EFA::Stop; @@ -91,11 +91,11 @@ sub new { mode => 'direct', nameInfo_dm => 'invalid', nameState_dm => 'empty', - name_dm => encode( 'ISO-8859-15', $opt{name} ), + name_dm => encode( 'UTF-8', $opt{name} ), outputFormat => 'XML', placeInfo_dm => 'invalid', placeState_dm => 'empty', - place_dm => encode( 'ISO-8859-15', $opt{place} ), + place_dm => encode( 'UTF-8', $opt{place} ), ptOptionsActive => '1', requestID => '0', reset => 'neue Anfrage', @@ -241,14 +241,14 @@ sub check_for_ambiguous { my $s_name = $e_name->getAttribute('state'); if ( $s_place eq 'list' ) { - $self->{place_candidates} = [ map { decode( 'UTF-8', $_->textContent ) } + $self->{place_candidates} = [ map { $_->textContent } @{ $e_place->findnodes($xp_place_elem) } ]; $self->{errstr} = 'ambiguous place parameter'; return; } if ( $s_name eq 'list' ) { - $self->{name_candidates} = [ map { decode( 'UTF-8', $_->textContent ) } - @{ $e_name->findnodes($xp_name_elem) } ]; + $self->{name_candidates} + = [ map { $_->textContent } @{ $e_name->findnodes($xp_name_elem) } ]; $self->{errstr} = 'ambiguous name parameter'; return; @@ -331,12 +331,12 @@ sub lines { @lines, Travel::Status::DE::EFA::Line->new( name => $line, - direction => decode( 'UTF-8', $direction ), + direction => $direction, valid => $valid, - type => decode( 'UTF-8', $type ), + type => $type, mot => $mot, - route => decode( 'UTF-8', $route ), - operator => decode( 'UTF-8', $operator ), + route => $route, + operator => $operator, identifier => $identifier, ) ); @@ -371,8 +371,8 @@ sub parse_route { arr_time => sprintf_time( $times[0] ), dep_date => sprintf_date( $dates[-1] ), dep_time => sprintf_time( $times[-1] ), - name => decode( 'UTF-8', $e->getAttribute('name') ), - name_suf => decode( 'UTF-8', $e->getAttribute('nameWO') ), + name => $e->getAttribute('name'), + name_suf => $e->getAttribute('nameWO'), platform => $e->getAttribute('platformName'), ) ); @@ -492,9 +492,9 @@ sub results { key => $key, lineref => $line_obj[0] // undef, line => $line, - destination => decode( 'UTF-8', $dest ), + destination => $dest, countdown => $countdown, - info => decode( 'UTF-8', $info ), + info => $info, delay => $delay, sched_date => $date, sched_time => $time, diff --git a/t/20-vrr.t b/t/20-vrr.t index 95eb7a3..31fa6ca 100644 --- a/t/20-vrr.t +++ b/t/20-vrr.t @@ -30,7 +30,7 @@ for my $result (@results) { can_ok($result, qw(date destination info line time type platform)); } -is($results[0]->destination, decode('UTF-8', 'Düsseldorf Hbf'), 'first result: destination ok'); +is($results[0]->destination, 'Düsseldorf Hbf', 'first result: destination ok'); is($results[0]->info, 'Bordrestaurant', 'first result: no info'); is($results[0]->line, 'ICE 946 Intercity-Express', 'first result: line ok'); is($results[0]->date, '16.11.2011', 'first result: real date ok'); @@ -42,8 +42,8 @@ is($results[0]->mot_name, 'zug', 'first result: mot_name ok'); #is($results[0]->platform, '1', 'first result: platform ok'); #is($results[0]->platform_db, 1, 'first result: platform_db ok'); -is($results[3]->destination, decode('UTF-8', 'Mülheim Heißen Kirche'), 'fourth result: destination ok'); -is($results[3]->info, decode('UTF-8', 'Ab (H) Heißen Kirche, Umstieg in den SEV Ri. Mülheim Hbf.'), 'fourth result: no info'); +is($results[3]->destination, 'Mülheim Heißen Kirche', 'fourth result: destination ok'); +is($results[3]->info, 'Ab (H) Heißen Kirche, Umstieg in den SEV Ri. Mülheim Hbf.', 'fourth result: no info'); is($results[3]->line, '18', 'fourth result: line ok'); is($results[3]->date, '16.11.2011', 'fourth result: real date ok'); is($results[3]->time, '09:39', 'fourth result: real time ok'); @@ -55,7 +55,7 @@ is($results[3]->mot_name, 'u-bahn', 'fourth result: mot_name ok'); #is($results[3]->platform_db, 0, 'fourth result: platform_db ok'); is($results[-1]->destination, 'Hamm (Westf)', 'last result: destination ok'); -is($results[-1]->info, decode('UTF-8', 'Fahrradmitnahme begrenzt möglich'), 'last result: info ok'); +is($results[-1]->info, 'Fahrradmitnahme begrenzt möglich', 'last result: info ok'); is($results[-1]->delay, 12, 'last result: delay 12'); is($results[-1]->line, 'RE1', 'last result: line ok'); is($results[-1]->date, '16.11.2011', 'last result: date ok'); -- cgit v1.2.3