13 my ($enc, $content, $do_bom) = @_;
14 my $template = $templates{$enc};
15 die "Unsupported encoding $enc" unless $template;
16 return pack "$template*", ($do_bom ? 0xFEFF : ()), unpack "C*", $content;
20 my ($enc, $tag, $bom, $nl) = @_;
21 open my $fh, ">", "utf$$.pl" or die "utf.pl: $!";
23 print $fh bytes_to_utf($enc, $tag . ($nl ? "\n" : ''), $bom);
25 my $got = do "./utf$$.pl";
28 print "not ok $test # $enc $tag $bom $nl; got undef\n";
29 } elsif ($got ne $tag) {
30 print "not ok $test # $enc $tag $bom $nl; got '$got'\n";
32 print "ok $test # $enc $tag $bom $nl\n";
37 for my $enc (qw(utf16le utf16be utf8)) {
38 for my $value (123, 1234, 12345) {
40 test($enc, $value, $bom, $nl);
47 1 while unlink "utf$$.pl";