One might want to use Unicode::UTF8[1] instead of the hand-rolled helper:<p><pre><code> #!/usr/bin/perl
use strict;
use warnings FATAL => 'utf8'
use open ':std', ':encoding(UTF-8)';
use Time::Piece;
use Unicode::UTF8 qw( decode_utf8 );
for my $month (1 .. 12) {
my $date = sprintf '2021-%02d-01', $month;
my $tp = Time::Piece->strptime($date, '%Y-%m-%d');
print decode_utf8($tp->strftime('%B')), ' ' x ($month != 12);
}
print "\n";
</code></pre>
> Here is a summary of features for comparison with Encode's UTF-8 implementation:<p>> * Simple API which makes use of Perl's standard warning categories.<p>> * Recognizes all noncharacters regardless of Perl version<p>> * Implements Unicode's recommended practice for using U+FFFD.<p>> * Better diagnostics in warning messages<p>> * Detects and reports inconsistency in Perl's internal representation of wide characters (UTF-X)<p>> * Preserves taintedness of decoded $octets or encoded $string<p>> * Better performance ~ 600% - 1200% (JA: 600%, AR: 700%, SV: 900%, EN: 1200%, see benchmarks directory in git repository)<p>[1]: <a href="https://metacpan.org/pod/Unicode::UTF8" rel="nofollow">https://metacpan.org/pod/Unicode::UTF8</a>