The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Encode::Locale - Determine the locale encoding

SYNOPSIS

  use Encode::Locale;
  use Encode;

  $string = decode(locale => $octets);

  binmode(STDIN, ":encoding(locale)");
  binmode(STDOUT, ":encoding(locale)");

DESCRIPTION

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:

decode_argv()
decode_argv( Encode::FB_CROAK )

This will decode the command line arguments to perl (the @ARGV array) in-place.

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.

env( $uni_key )
env( $uni_key => $uni_value )

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.

The returned value will have the characters that can't be decoded replaced by "\x{FFFD}", the Unicode replacement character.

$ENCODING_LOCALE

The encoding name determined to be suitable for the current locale. Encode know this encoding as "locale".

$ENCODING_LOCALE_FS

The encoding name determined to be suiteable for file system interfaces involving file names. Encode know this encoding as "locale_fs".

$ENCODING_CONSOLE_IN
$ENCODING_CONSOLE_OUT

The encodings to be used for reading and writing output to the a console. Encode know these encodings as "console_in" and "console_out".

SEE ALSO

I18N::Langinfo, Encode

AUTHOR

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.