Your example script will never give such an error since you never tell Perl that any of your data might be anything other than Latin-1 bytes. So Perl reads and writes the data as Latin-1 bytes and sees no reason to warn.
You can only get this warning when you use Encode::decode explicitly or when you (or a module you use) decode your data from a character set encoding to Unicode implicitly, for example by
open my $fh, '<:encoding(UTF-8)', $filename or die "Couldn't open '$filename': $!";
Maybe Perl 5.24 warns in more situations than Perl 5.16 did when writing Unicode strings to a file (or somewhere else).
To correct the situation Perl warns about, be explicit in your output encoding and open your output files as
open my $fh, '>:encoding(UTF-8)', $filename or die "Couldn't open '$filename': $!";
... or encode your strings to bytes before writing them:
use charnames ':full'; use Encode 'encode'; open my $fh, '>', $filename or die "Couldn't create '$filename': $!"; my $output = "MOT\N{CAPITAL LETTER O WITH DIAERESIS}RHEAD"; my $output_bytes = encode( 'UTF-8', $output ); print $fh $output_bytes;
In reply to Re: UTF8 - Same script, different behaviour
by Corion
in thread UTF8 - Same script, different behaviour
by Melly
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |