4 ms·
The way Perl dealt with this was to have you declare when you are using UTF8. # declare that the code itself is written in utf8 use utf8; my $ā =
by b2gills 6y ago
The way Perl dealt with this was to have you declare when you are using UTF8.
# declare that the code itself is written in utf8
use utf8;
my $ā = 'ā';
If you need unicode strings to work, you turn on the unicode strings feature.
use feature 'unicode_strings';
Another way to turn it on:
use v5.12;
(Declaring which version of the language you need is something you should do anyway.)
Really mostly what you have to do is declare the encodings of the file handles.
# change it for all files
use open ':encoding(UTF-8)';
To change it per file handle, you would use `binmode`. (Which was originally added to allow binary code to work on Windows.)
open my $fh, '<', 'example.txt';
binmode $fh, ':utf8';
(Declaring the encoding of an opened file is something you should do anyway.)
---
Basically Perl just defaults to the old original ways. If you need a new feature which would break old code, you just declare that you need it.
Because of that, most code that was written for an earlier form of Perl still works on the latest version.