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

NAME

Encode::Registry - Registry file handling for character encodings

SYNOPSIS

    use Encode::Registry;

    $enc = Encode::Registry->find_encoding($enc_name);
    $uni_str = $enc->decode($byte_str);
    $byte_str = $enc->encode($uni_str);

DESCRIPTION

The Encode module provides a Perl interface to the cross-architecture registry of character encoding information. This registry takes the form of an XML file containing information about encoding files, their types and handlers for different file types on different platforms (or programming environments).

Encoding Types

Locating the Registry file

Having a central registry for encodings is very useful, assuming you can find it. But tracking down such a registry given that it may be shared by many programming environments, is not easy.

On the Windows platform, this module will look for the registry file in the system registry under the following key

    HKEY_LOCAL_MACHINE\SOFTWARE\Mapping\Registry\File

which is held as a string.

Failing this, and on other systems, the module will examine the MAPPINGPATH environment variable and look in each directory listed for a file REGISTRY.xml. Directories in the environment variable are separated by a ;

MODULE

To use the module, simply use it.

    use Encode::Registry

This will cause the import subroutine to run which will search for a REGISTRY.xml and read it. If nothing is found, then nothing will be read.

To load the highest priority implementation of an encoding, use:

    $enc = Encode::Registry->find_encoding($enc_name);
    $utf8 = $enc->decode($bytes);
    $bytes = $enc->encode($utf8);

Methods

Encode::Registry->find_registry

Returns an absolute file name reference to the registry file, if it can find it.

Encode::Registry->read_file($fname)

Reads and processes the given XML file adding the information to the internal data structures of this class.

Encode::Registry->find_encoding($name)

Returns an object capable of processing data of the given encoding. The object is created by calling

    $handler->new($system_file)

Where $handler is the associated handler for the given file type of $system_file. The $handler with the highest priority is chosen.

Encode::Registry->add_handler($type, $handler, $priority)

Adds the given type to be handled by the handler module when using Perl. The priority is also set this way.