in reply to Re^4: function length() in UTF-8 context
in thread function length() in UTF-8 context
Is it possible to "switch" a script in such a way that ALL outputs get encoded with respect to some locale setting we can read from the system?
#!/usr/bin/perl # This source file is encoded using UTF-8. use utf8; use strict; use warnings; # Use locale-dependent encoding for STDIO. use open ':std', ':locale'; # Use locale-dependent encoding (by default) # for all files opened in this scope. # Unfortunately, <> ignores this directive. use open IO => ':locale'; ...
It might makes more sense to use a known encoding for files, though.
use open IO => ':encoding(UTF-8)';
There's also File::BOM in case you want to accepts UTF-8 (and -16le and -16be) while giving allowing a fallback to another encoding such as iso-latin-1.
|
|---|