Encode::Locale - Determine the locale encoding
use Encode::Locale; use Encode; $string = decode(locale => $octets); binmode(STDIN, ":encoding(locale)"); binmode(STDOUT, ":encoding(locale)");
Perl uses Unicode to represent strings internally but many of the interfaces it has to the outside world is still byte based. Programs therefore needs to decode strings that enter the program from the outside and encode them again on the way out.
The POSIX locale system is used to specify both the language conventions to use and the prefered character set to consume and output. This module looks up the charset (called a CODESET in the locale jargon) and arrange for the Encode module to know this encoding under the name "locale".
In addition the following functions and variables are provided:
This will decode the command line arguments to perl (the @ARGV array) in-place.
@ARGV
The function will by default replace characters that can't be decoded by "\x{FFFD}", the Unicode replacement character.
Any argument provided is passed as CHECK to underlying Encode::decode() call. Pass the value Encode::FB_CROAK to have the decoding croak if not all the command line arguments can be decoded. See "Handling Malformed Data" in Encode for details on other options for CHECK.
Encode::FB_CROAK
Interface to get/set environment variables. Returns the current value as a Unicode string. The $uni_key and $uni_value arguments are expected to be Unicode strings as well. Passing undef as $uni_value deletes the environment variable named $uni_key.
undef
The returned value will have the characters that can't be decoded replaced by "\x{FFFD}", the Unicode replacement character.
The encoding name determined to be suitable for the current locale. Encode know this encoding as "locale".
The encoding name determined to be suiteable for file system interfaces involving file names. Encode know this encoding as "locale_fs".
The encodings to be used for reading and writing output to the a console. Encode know these encodings as "console_in" and "console_out".
I18N::Langinfo, Encode
Copyright 2010 Gisle Aas <gisle@aas.no>.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Encode::Locale, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Encode::Locale
CPAN shell
perl -MCPAN -e shell install Encode::Locale
For more information on module installation, please visit the detailed CPAN module installation guide.