1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# Test Unicode entities
use HTML::Entities;
use Test::More tests => 27;
SKIP: {
skip "This perl does not support Unicode or Unicode entities not selected",
27 if $] < 5.008 || !&HTML::Entities::UNICODE_SUPPORT;
is(decode_entities("&euro"), "&euro");
is(decode_entities("€"), "\x{20AC}");
is(decode_entities("å"), "å");
is(decode_entities("å"), "å");
is(decode_entities("񺄠"), chr(500000));
is(decode_entities("􏿽"), "\x{10FFFD}");
is(decode_entities(""), "\x{FFFC}");
is(decode_entities(""), "\x{FFFD}");
is(decode_entities(""), "\x{FFFD}");
is(decode_entities(""), "\x{FFFD}");
is(decode_entities(""), "\x{FFFD}");
is(decode_entities(""), "\x{FFFD}");
is(decode_entities(""), "\x{FFFD}");
is(decode_entities("�"), chr(0xFFFD));
is(decode_entities("�"), chr(0xFFFD));
is(decode_entities("�"), "\0");
is(decode_entities("�"), "\0");
is(decode_entities("�"), "\0");
is(decode_entities("�"), "\0");
is(decode_entities("&#ååå࿿"), "&#ååå\x{FFF}");
# This might fail when we get more than 64 bit UVs
is(decode_entities("�"), "�");
is(decode_entities("�"), "�");
my $err;
for ([32, 48], [120, 169], [240, 250], [250, 260], [965, 975], [3000, 3005]) {
my $a = join("", map chr, $_->[0] .. $_->[1]);
my $e = encode_entities($a);
my $d = decode_entities($e);
unless ($d eq $a) {
diag "Wrong decoding in range $_->[0] .. $_->[1]";
# use Devel::Peek; Dump($a); Dump($d);
$err++;
}
}
ok(!$err);
is(decode_entities("��"), chr(0x100085));
is(decode_entities("��"), chr(0x100085));
is(decode_entities("�"), chr(0xFFFD));
is(decode_entities("\260’\260"), "\x{b0}\x{2019}\x{b0}");
}
|