perldoc > Unicode::MapUTF8

📖 NAME

Unicode::MapUTF8 - Conversions to and from arbitrary character sets and UTF8

🚀 Quick Reference

Use CaseCommandDescription
Convert from charset to UTF8to_utf8({ -string => $string, -charset => $source })Convert string from any supported charset to UTF8
Convert from UTF8 to charsetfrom_utf8({ -string => $string, -charset => $target })Convert string from UTF8 to any supported charset
List supported charsetsutf8_supported_charset()Return list of all supported charset names (including aliases)
Check if charset is supportedutf8_supported_charset('ISO-8859-1')Returns true if the named charset is supported
Add a charset aliasutf8_charset_alias({ 'japanese' => 'sjis' })Define a runtime alias for a supported charset
Get defined aliasesutf8_charset_alias()Returns hashref of alias => real charset mappings
Clear an aliasutf8_charset_alias({ 'japanese' => undef })Remove an alias definition
Convert between two arbitrary charsetsto_utf8(...) then from_utf8(...)Chain to_utf8 and from_utf8 to convert e.g. SJIS to EUC-JP

📋 SYNOPSIS

use Unicode::MapUTF8 qw(to_utf8 from_utf8 utf8_supported_charset);

# Convert a string in 'ISO-8859-1' to 'UTF8'
my $output = to_utf8({ -string => 'An example', -charset => 'ISO-8859-1' });

# Convert a string in 'UTF8' encoding to encoding 'ISO-8859-1'
my $other  = from_utf8({ -string => 'Other text', -charset => 'ISO-8859-1' });

# List available character set encodings
my @character_sets = utf8_supported_charset;

# Add a character set alias
utf8_charset_alias({ 'ms-japanese' => 'sjis' });

# Convert between two arbitrary (but largely compatible) charset encodings
# (SJIS to EUC-JP)
my $utf8_string   = to_utf8({ -string =>$sjis_string, -charset => 'sjis'});
my $euc_jp_string = from_utf8({ -string => $utf8_string, -charset => 'euc-jp' })

# Verify that a specific character set is supported
if (utf8_supported_charset('ISO-8859-1') {
    # Yes
}

📝 DESCRIPTION

Provides an adapter layer between core routines for converting to and from UTF8 and other encodings. In essence, a way to give multiple existing Unicode modules a single common interface so you don't have to know the underlaying implementations to do simple UTF8 to-from other character set encoding conversions. As such, it wraps the Unicode::String, Unicode::Map8, Unicode::Map and Jcode modules in a standardized and simple API.

This also provides general character set conversion operation based on UTF8 - it is possible to convert between any two compatible and supported character sets via a simple two step chaining of conversions.

As with most things Perlish - if you give it a few big chunks of text to chew on instead of lots of small ones it will handle many more characters per second.

By design, it can be easily extended to encompass any new charset encoding conversion modules that arrive on the scene.

This module is intended to provide good Unicode support to versions of Perl prior to 5.8. If you are using Perl 5.8.0 or later, you probably want to be using the Encode module instead. This module does work with Perl 5.8, but Encode is the preferred method in that environment.

📜 CHANGES

🔧 FUNCTIONS

đŸ› ī¸ utf8_charset_alias({ $alias => $charset })

Used for runtime assignment of character set aliases.

Called with no parameters, returns a hash of defined aliases and the character sets they map to.

Example:

my $aliases     = utf8_charset_alias;
my @alias_names = keys %$aliases;

If called with ONE parameter, returns the name of the 'real' charset if the alias is defined. Returns undef if it is not found in the aliases.

Example:

if (! utf8_charset_alias('VISCII')) {
    # No alias for this
}

If called with a list of 'alias' => 'charset' pairs, defines those aliases for use.

Example:

utf8_charset_alias({ 'japanese' => 'sjis', 'japan' => 'sjis' });

Note: It will croak if a passed pair does not map to a character set defined in the predefined set of character encoding. It is NOT allowed to alias something to another alias.

Multiple character set aliases can be set with a single call.

To clear an alias, pass a character set mapping of undef.

Example:

utf8_charset_alias({ 'japanese' => undef });

While an alias is set, the 'utf8_supported_charset' function will return the alias as if it were a predefined charset.

Overriding a base defined character encoding with an alias will generate a warning message to STDERR.

đŸ› ī¸ utf8_supported_charset($charset_name)

Returns true if the named charset is supported (including user defined aliases).

Returns false if it is not.

Example:

if (! utf8_supported_charset('VISCII')) {
    # No support yet
}

If called in a list context with no parameters, it will return a list of all supported character set names (including user defined aliases).

Example:

my @charsets = utf8_supported_charset;

đŸ› ī¸ to_utf8({ -string => $string, -charset => $source_charset })

Returns the string converted to UTF8 from the specified source charset.

đŸ› ī¸ from_utf8({ -string => $string, -charset => $target_charset})

Returns the string converted from UTF8 to the specified target charset.

đŸˇī¸ VERSION

1.14 2020.09.27

đŸ—“ī¸ TODO

Regression tests for Jcode, 2-byte encodings and encoding aliases

🔗 SEE ALSO

Unicode::String Unicode::Map8 Unicode::Map Jcode Encode

ÂŠī¸ COPYRIGHT

Copyright 2000-2020, Jerilyn Franz. All rights reserved.

👤 AUTHOR

Jerilyn Franz <cpan AT jerilyn.info>

âš–ī¸ LICENSE

MIT License

Copyright (c) 2020 Jerilyn Franz

Permission is hereby granted, free of charge, to any person obtaining a copy of this software
and associated documentation files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Unicode::MapUTF8
📖 NAME 🚀 Quick Reference 📋 SYNOPSIS 📝 DESCRIPTION 📜 CHANGES 🔧 FUNCTIONS
đŸ› ī¸ utf8_charset_alias({ $alias => $charset }) đŸ› ī¸ utf8_supported_charset($charset_name) đŸ› ī¸ to_utf8({ -string => $string, -charset => $source_charset }) đŸ› ī¸ from_utf8({ -string => $string, -charset => $target_charset})
đŸˇī¸ VERSION đŸ—“ī¸ TODO 🔗 SEE ALSO ÂŠī¸ COPYRIGHT 👤 AUTHOR âš–ī¸ LICENSE

Generated by phpman v4.10.0-7-g98e9fd5 · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-09-15 06:44 @216.73.217.167
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Valid XHTML 1.0 Transitional!Valid CSS!

^_top_^