in reply to Re^3: Processing an encoded file backwards
in thread Processing an encoded file backwards
providing a call back helps identifying the malformed bytes
DB<131> dd $rr "\x84\xC3\x96\xC3\x9C.\r\n\r\n" DB<132> $start=0 DB<133> $rru = Encode::decode('utf8',$rr, sub{ my $broken = shift; $ +start++; "" }); DB<134> dd $rru "\xD6\xDC.\r\n\r\n" DB<135> p $start 1 DB<136>
> I don't use the debugger often, so reading its output doesn't come naturally to me ;-)
as commented
furthermore debugger commands
DB<79> h p p expr Same as "print {DB::OUT} expr" in current package. DB<80> h x x expr Evals expression in list context, dumps the result.
one way to identify how many malformed bytes are at the start and to be sure the rest is well.
DB<159> $start=0 DB<160> $rru = Encode::decode('utf8',$rr,sub{ $start++; return "" }) +; DB<161> $sub= substr $rr,$start DB<162> $rru2 = Encode::decode('utf8',$sub ,Encode::FB_CROAK); DB<163> p $rru2 eq $rru 1 DB<164>
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
FootballPerl is like chess, only without the dice
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Processing an encoded file backwards
by haukex (Archbishop) on Jan 18, 2020 at 21:53 UTC | |
by LanX (Saint) on Jan 18, 2020 at 22:30 UTC | |
by choroba (Cardinal) on Jan 18, 2020 at 23:13 UTC | |
by LanX (Saint) on Jan 18, 2020 at 23:27 UTC | |
by LanX (Saint) on Jan 18, 2020 at 23:19 UTC | |
by choroba (Cardinal) on Jan 18, 2020 at 23:46 UTC | |
| |
by haukex (Archbishop) on Jan 19, 2020 at 12:05 UTC | |
|