NAME

UnicodeTable - Create compressed Unicode tables for C programs

SYNOPSIS

my $table = UnicodeTable->read(
    filename => $filename,
    type     => 'Enumerated',
    map      => \%map,
);

my $comp = $table->compress($shift);

$comp->dump;

DESCRIPTION

This module creates compressed tables used to lookup Unicode properties in C programs. To compress a table, it's split into blocks of a fixed size. Identical blocks are discovered and only unique blocks are written to the compressed table. An additional map table is created to map original block indices to block ids.

The map tables can then be compressed again using the same algorithm.

Powers of two are used as block sizes, so the table indices to lookup values can be computed using bit operations.

METHODS

new

my $table = UnicodeTable->new(
    values    => \@values,
    default   => $default,
    max       => $max,
    shift     => $shift,
    map_table => $map_table,
);

\@values is an arrayref with the table values, $max is the maximum value. The default value for undefined table entries is $default or 0. $shift and $map_table are used for compressed tables.

read

my $table = UnicodeTable->table(
    filename => $filename,
    type     => $type,
    map      => \%map,
    default  => $default,
);

Reads a table from a Unicode data text file. $type is either 'Enumerated' or 'Boolean'. \%map is a hashref that maps property values to integers. For booleans, these integers are ORed. $default is the default value passed to new.

shift

mask

max

map_table

Accessors

set

$table->set($i, $value);

Set entry at index $i to $value. Don't use with compressed tables.

size

my $size = $table->size;

Storage size of the table in bytes.

lookup

my $value = $table->lookup($i);

Lookup value at index $i. Also works with compressed tables.

compress

my $compressed_table = $table->compress($shift);

Returns a compressed version of this table which is linked to a second map table. Blocks of size (1 << $shift) are used.

compress_map

my $map_table = $table->compress_map($shift);

Compress the map table of a table for multi stage lookup. Returns the compressed map table.

dump

$table->dump($file, $name);

Dump the table as C code to filehandle $file. The table name is $name.

AUTHOR

Nick Wellnhofer <wellnhofer@aevum.de>