| 1 | package HTML::HTML5::Parser::Charset::UniversalCharDet; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | ## skip Test::Tabs | ||||||||||||||||||||||||||||
| 4 | 9 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 9 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 9 | ▶ | use IO::HTML (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 9 | our $VERSION='0.991'; | |||||||||||||||||||||||||||
| 9 | 9 | our $DEBUG; | |||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | # this really shouldn't work, but for some reason it does... | ||||||||||||||||||||||||||||
| 12 | sub _detect { | ||||||||||||||||||||||||||||
| 13 | 708 | ▶ | return +{ encoding => 'UTF-8' } if !utf8::is_utf8($_[0]); # huh? | ||||||||||||||||||||||||||
|
Subroutine
_detect: called CC=3 SCAR=19.8
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 14 | 0 | open my $fh, '<:raw', \$_[0]; | |||||||||||||||||||||||||||
| 15 | 0 | my $e = IO::HTML::sniff_encoding($fh => 'string'); | |||||||||||||||||||||||||||
| 16 | 0 | ▶ | return +{ encoding => $e } if defined $e; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 17 | 0 | return +{}; | |||||||||||||||||||||||||||
| 18 | } | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | sub detect_byte_string ($$) { | ||||||||||||||||||||||||||||
| 21 | 708 | ▶ | my $de; | ||||||||||||||||||||||||||
|
Subroutine
detect_byte_string: called CC=6 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 22 | eval { | ||||||||||||||||||||||||||||
| 23 | 708 | $de = _detect $_[1]; | |||||||||||||||||||||||||||
| 24 | 708 | 1; | |||||||||||||||||||||||||||
| 25 | 708 | ▶ | } or do { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 26 | 0 | ▶ | warn $@ unless $DEBUG; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 27 | 0 | ▶ | die $@ if $DEBUG; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 28 | }; | ||||||||||||||||||||||||||||
| 29 | 708 | ▶ | if (defined $de and defined $de->{encoding}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $de and defined $de->{"encoding"}
MC/DC0%0/2
defined $de and defined $de->{"encoding"}
defined $de
defined $de->{"encoding"}
Truth table33%1/3
A and B
A= defined $deB= defined $de->{"encoding"}
| |||||||||||||||||||||||||||||
| 30 | 708 | return lc $de->{encoding}; | |||||||||||||||||||||||||||
| 31 | } else { | ||||||||||||||||||||||||||||
| 32 | 0 | return undef; | |||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||
| 34 | } # detect_byte_string | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | #Copyright 2007-2011 Wakaba <w@suika.fam.cx> | ||||||||||||||||||||||||||||
| 37 | #Copyright 2009-2012 Toby Inkster <tobyink@cpan.org> | ||||||||||||||||||||||||||||
| 38 | # | ||||||||||||||||||||||||||||
| 39 | #This library is free software; you can redistribute it | ||||||||||||||||||||||||||||
| 40 | #and/or modify it under the same terms as Perl itself. | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 9 | 1; | |||||||||||||||||||||||||||