1# tell parser the source POD has already been decoded from bytes to chars
2# =encoding line should be ignored
3# utf8 characters should come through unscathed
4
5BEGIN {
6    if($ENV{PERL_CORE}) {
7        chdir 't';
8        @INC = '../lib';
9    }
10
11    use Config;
12    if ($Config::Config{'extensions'} !~ /\bEncode\b/) {
13      print "1..0 # Skip: Encode was not built\n";
14      exit 0;
15    }
16}
17
18use strict;
19use Test;
20BEGIN { plan tests => 3 };
21
22use Pod::Simple::DumpAsXML;
23use Pod::Simple::XMLOutStream;
24
25
26my $parser = Pod::Simple::XMLOutStream->new;
27$parser->parse_characters(1);
28my $output = '';
29$parser->output_string( \$output );
30$parser->parse_string_document(qq{
31
32=encoding bogocode
33
34=head1 DESCRIPTION
35
36Confirm that if we tell the parser to expect character data, it avoids all
37the code paths that might attempt to decode the source from bytes to chars.
38
39The r\x{101}in in \x{15E}pain \x{FB02}oods the plain
40
41});
42
43ok(1); # parsed without exception
44
45if($output =~ /POD ERRORS/) {
46  ok(0);
47}
48else {
49  ok(1); # no errors
50}
51
52$output =~ s{&#(\d+);}{chr($1)}eg;
53
54if($output =~ /The r\x{101}in in \x{15E}pain \x{FB02}oods the plain/) {
55  ok(1); # data was not messed up
56}
57else {
58  ok(0);
59}
60
61exit;
62