File: charsets.pl

package info (click to toggle)
libhtml-html5-parser-perl 0.992-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,444 kB
  • sloc: perl: 16,129; makefile: 2; sh: 1
file content (22 lines) | stat: -rw-r--r-- 649 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
use utf8::all;
use HTML::HTML5::Parser;

my $U = HTML::HTML5::Parser->load_html(location => 'examples/html/utf-8.html');
my $X = HTML::HTML5::Parser->load_html(location => 'examples/html/utf-16.html');
my $W = HTML::HTML5::Parser->load_html(location => 'examples/html/iso-8859-15.html');

print "UTF-8...   ",
	$U->getElementsByTagName('p')->[0]->textContent,
	"\t",
	HTML::HTML5::Parser->charset($U),
	"\n";
print "UTF-16..   ",
	$X->getElementsByTagName('p')->[0]->textContent,
	"\t",
	HTML::HTML5::Parser->charset($X),
	"\n";
print "Western... ",
	$W->getElementsByTagName('p')->[0]->textContent,
	"\t",
	HTML::HTML5::Parser->charset($W),
	"\n";