enc2xs
Convert encoding files to Perl extension code
SYNOPSIS
enc2xs [-C directory] [-D directory] [-G] [-H] [-o output] [-p] [-P] [-Q] [-S scheme] [-v] [-X] [-?] encoding [alias ...]
PARAMETERS
-C directory
Directory for charset conversion tables (default: Encode lib dirs)
-D directory
Base directory for output modules (default: Encode/lib)
-G
Generate Guess.pm tables for Encode::Guess
-H
Generate XS header file
-o outputfilename
Output Perl module filename (default: Encode/encoding.pm)
-p
Generate POD documentation (default)
-P
Do not generate POD
-Q
Quiet mode; no progress indicator
-S scheme
Mapping scheme (default: default)
-v
Verbose output
-X
No XS file; pure Perl only
-? or --help
Display help
DESCRIPTION
enc2xs is a Perl utility from the Encode module that converts MIME character set maps into ready-to-use Perl modules. It reads encoding tables from system directories (typically under Perl's Encode lib dir) or a specified path, generating .pm files with encode/decode functions, XS C code for speed, and optional POD documentation.
Invoke with an encoding name like enc2xs utf8 to create Encode::utf8.pm. Aliases can be added, e.g., enc2xs euc-jp EUC-JP-2000. The tool handles various schemes (e.g., default, 1_to_1) and supports custom output dirs.
This enables easy addition of encoding support in Perl scripts without manual XS coding. It's essential for internationalization, processing text in encodings like ISO-8859, EUC, Shift-JIS. Generated modules integrate seamlessly with use Encode 'encoding';, providing encode() and decode() functions.
Progress shows table loading; verbose mode details steps. Quiet mode suppresses output.
CAVEATS
Requires pre-built encoding maps; fails if map not found. XS generation needs C compiler. Not for dynamic/runtime encodings.
EXAMPLE
enc2xs -D lib euc-jp
Creates lib/Encode/EUCJP.pm for EUC-JP encoding.
MAP FILES
Supports UCS2, map files from iconv or Encode sources; check @INC/Encode dir.
HISTORY
Introduced in Perl 5.8.0 (2002) with Encode module. Enhanced in later versions for more schemes, Guess support, and better map handling.


