perldoc > Unicode::Map8

📛 NAME

Unicode::Map8 - Mapping table between 8-bit chars and Unicode

🚀 Quick Reference

Use CaseCommandDescription
Create a mapping object$m = Unicode::Map8->new("latin1");Load Latin-1 mapping
Convert 8-bit to 16-bit (UCS2)$u16 = $m->to16($str8);Returns network-byte-order UCS2 string
Convert 16-bit to 8-bit$str8 = $m->to8($u16);Back to 8-bit charset
Recode between two charsets$m1->recode8($m2, $str);Convert $str from charset1 to charset2
Add a custom mapping pair$m->addpair(0x80, 0x20AC);Map 0x80 to Euro sign
Get a Unicode::String object$us = $m->tou($str8);Returns Unicode::String instead of raw UCS2
Set default fallback characters$m->default_to8(0x3F);
$m->default_to16(0xFFFD);
Define defaults for unmapped chars

📝 SYNOPSIS

require Unicode::Map8;
my $no_map = Unicode::Map8->new("ISO646-NO") || die;
my $l1_map = Unicode::Map8->new("latin1")    || die;

my $ustr = $no_map->to16("V}re norske tegn b|r {res\n");
my $lstr = $l1_map->to8($ustr);
print $lstr;

print $no_map->tou("V}re norske tegn b|r {res\n")->utf8

📖 DESCRIPTION

The Unicode::Map8 class implement efficient mapping tables between 8-bit character sets and 16 bit character sets like Unicode. The tables are efficient both in terms of space allocated and translation speed. The 16-bit strings is assumed to use network byte order.

🔧 Methods

🔧 Callback Methods

The following callback methods are available. You can override these methods by creating a subclass of Unicode::Map8.

📁 FILES

The Unicode::Map8 constructor can parse two different file formats; a binary format and a textual format.

🗂️ Binary format: It consists of a sequence of 16-bit integer pairs in network byte order. The first pair should contain the magic value 0xFFFE, 0x0001. Of each pair, the first value is the code of an 8-bit character and the second is the code of the 16-bit character. It follows that the first value should be less than 256.

📄 Textual format: It consists of lines that are either a comment (first non-blank character is '#'), a completely blank line, or a line with two hexadecimal numbers. The hexadecimal numbers must be preceded by "0x" as in C and Perl. This is the same format used by the Unicode mapping files available from <URL:ftp://ftp.unicode.org/Public>.

The mapping table files are installed in the Unicode/Map8/maps directory somewhere in the Perl @INC path. The variable $Unicode::Map8::MAPS_DIR is the complete path name to this directory. Binary mapping files are stored within this directory with the suffix .bin. Textual mapping files are stored with the suffix .txt.

The scripts map8_bin2txt and map8_txt2bin can translate between these mapping file formats.

A special file called aliases within $MAPS_DIR specifies all the alias names that can be used to denote the various character sets. The first name of each line is the real file name and the rest are alias names separated by space.

The umap --list command can be used to list the character sets supported.

🐛 BUGS

Does not handle Unicode surrogate pairs as a single character.

📚 SEE ALSO

umap(1), Unicode::String

⚖️ COPYRIGHT

Copyright 1998 Gisle Aas.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

Unicode::Map8
📛 NAME 🚀 Quick Reference 📝 SYNOPSIS 📖 DESCRIPTION
🔧 Methods 🔧 Callback Methods
📁 FILES 🐛 BUGS 📚 SEE ALSO ⚖️ COPYRIGHT

Generated by phpman v4.9.29 · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-07-20 18:16 @2600:1f28:365:80b0:8802:8bb4:3873:328e
CrawledBy CCBot/2.0 (https://commoncrawl.org/faq/)
Valid XHTML 1.0 Transitional!Valid CSS!
Enhanced by LLM: deepseek-v4-flash / taotoken.net / www.chedong.com - original format

^_top_^