1use strict; 2use Test::More; 3 4use Encode; 5use File::Temp; 6use File::Spec; 7 8# This test relies on https://github.com/Perl/perl5/issues/10623; 9# if that bug is ever fixed then this test may never fail again. 10 11my $foo = Encode::decode("UTF-16LE", "/\0v\0a\0r\0/\0f\0f\0f\0f\0f\0f\0/\0u\0s\0e\0r\0s\0/\0s\0u\0p\0e\0r\0m\0a\0n\0"); 12 13my ($fh, $path) = File::Temp::tempfile( CLEANUP => 1 ); 14 15note "temp file: $path"; 16 17# Perl gives the internal PV to exec .. which is buggy/wrong but 18# useful here: 19system( $^X, '-e', "open my \$fh, '>>', '$path' or die \$!; print {\$fh} \$ARGV[0]", $foo ); 20die if $?; 21 22my $output = do { local $/; <$fh> }; 23 24is( $output, "/var/ffffff/users/superman", 'UTF-16 decodes with trailing NUL' ); 25 26done_testing(); 27