I noticed that a patch recently submitted for Koha adds the following line to one of Koha’s Perl modules:
utf8 is a perfectly fine and proper Perl pragma, right? Indeed it is. The problem is that the purpose of the patch is to try to fix an issue with reading and displaying UTF-8 characters from a file. So what does
use utf8; contribute to that patch?
The only thing that the
utf8 pragma does is signal to the Perl interpreter that the Perl source code is in UTF-8. If you’re using non-ASCII characters in your source code, you’ll need the pragma. For example,
my $str = "La lluvia en España se mantiene principalmente en el llano!";
my $str_en_inglés = "The rain in Spain falls mostly on the plain!";
If what you’re actually trying to do is ensure that the script is handling UTF-8 input and output correctly,
use utf8; won’t help. This tutorial will.