GIF89a;
EcchiShell v1.0
/
/
proc/
self/
root/
usr/
share/
perl5/
, but unicode-strings are
downgraded with UTF-8 encoding. This happens because the first 256
codepoints in Unicode happens to agree with Latin-1.
However, this silent upgrading can easily cause problems, if you happen
to mix unicode strings with non-Latin1 data -- i.e. byte-strings encoded
in UTF-8 or other encodings. The error will not manifest until the
combined string is written to output, at which time it would be impossible
to see where did the silent upgrading occur.
=head2 Detecting the problem
This module simplifies the process of diagnosing such problems. Just put
this line on top of your main program:
use encoding::warnings;
Afterwards, implicit upgrading of high-bit bytes will raise a warning.
Ex.: C.
However, strings composed purely of ASCII code points (C<0x00>..C<0x7F>)
will I trigger this warning.
You can also make the warnings fatal by importing this module as:
use encoding::warnings 'FATAL';
=head2 Solving the problem
Most of the time, this warning occurs when a byte-string is concatenated
with a unicode-string. There are a number of ways to solve it:
=over 4
=item * Upgrade both sides to unicode-strings
If your program does not need compatibility for Perl 5.6 and earlier,
the recommended approach is to apply appropriate IO disciplines, so all
data in your program become unicode-strings. See L, L and
L for how.
=item * Downgrade both sides to byte-strings
The other way works too, especially if you are sure that all your data
are under the same encoding, or if compatibility with older versions
of Perl is desired.
You may downgrade strings with C and C.
See L and L for details.
=item * Specify the encoding for implicit byte-string upgrading
If you are confident that all byte-strings will be in a specific
encoding like UTF-8, I need not support older versions of Perl,
use the C pragma:
use encoding 'utf8';
Similarly, this will silence warnings from this module, and preserve the
default behaviour:
use encoding 'iso-8859-1';
However, note that C