Locale-Sensitive Perl Method
$success = utf8::downgrade($string, [ $fail_ok]);
$success = utf8_downgrade($string, [ $fail_ok]);
Internationalization (I18n) Method Overview
The utf8::downgrade function downgrades a string from UTF-8 to the 8-bit native encoding -
either Latin-1 or EBCDIC. It will fail (and return false if $fail_ok) if original string is not
representable in the native encoding.
Note that use of utf8::downgrade will turn of perl's UTF-8 flag.
See perl's UTF-8 utility functions
documentation and perlunicode
documentation for additional details.
I18n Issues
Use of utf8::downgrade most likely indicates that some element of the program is not UTF-8
compatible. It can be a signal that some refactoring is required.
Note that there are legitimate uses for utf8::downgrade . For instance, to increase the
performance of substr or length calls against an internal string. Assuming, of
course, that the string is known to be compatible with the system's native encoding. However, the use of
this function should still be regarded as suspicious. Beware of premature optimization.
Suggested Replacement
Globalyzer will detect this function and report it as an i18n issue. If you have determined that the call
is being handled correctly, you can use Globalyzer's Ignore Comment functionality to ensure that it
isn't picked up in a subsequent scan.
Locale-Sensitive Perl Methods
|