Convert::DUDE - Conversion between Unicode and DUDE
use Convert::DUDE ':all'; # handles 'dq--' prefix $domain = to_dude($utf8); $utf8 = from_dude($domain); # don't care about 'dq--' prefix # not exported by default $dudestr = dude_encode($utf8); $utf8 = dude_decode($dudestr);
This module provides functions to convert between DUDE (Differential Unicode Domain Encoding) and Unicode encodings.
Quoted from http://www.i-d-n.net/draft/draft-ietf-idn-dude-02.txt
DUDE is a reversible transformation from a sequence of nonnegative integer values to a sequence of letters, digits, and hyphens (LDH characters). DUDE provides a simple and efficient ASCII-Compatible Encoding (ACE) of Unicode strings for use with Internationalized Domain Names.
Following two functions are exported to your package when you use Convert::DUDE.
$domain = to_dude($utf8);
takes UTF8-encoded string, encodes it in DUDE and adds 'dq--' prefix in front.
$utf8 = from_dude($domain);
takes 'dq--' prefixed DUDE encoded string and decodes it to original UTF8 strings.
Following two functions can be exported to your package when you import them explicitly.
$dude = dude_encode($utf8);
takes UTF8-encoded string, encodes it in DUDE. Note that it doesn't care about 'dq--' prefix.
$utf8 = dude_decode($dude);
takes DUDE encoded string and decodes it to original UTF8 strings. Note that it doesn't care about 'dq--' prefix.
Those functions above may throw exeptions in case of error. You may have to catch 'em with eval block.
$prefix = Convert::DUDE->prefix; Convert::DUDE->prefix('xx--');
gets/sets DUDE prefix. 'dq--' for default.
Here's a sample code which does RACE-DUDE conversion.
use Convert::RACE; use Convert::DUDE; use Unicode::String qw(utf16); my $race = "bq--aewrcsy"; eval { my $utf16 = from_race($race); my $dude = to_dude(utf16($utf16)->utf8); print "RACE: $race => DUDE: $dude\n"; }; if ($@) { warn "Conversion failed: $@"; }
There's no constraints on the input. See internet draft for nameprep about IDN input validation.
Consider mixed-case annotation. See internet draft for DUDE for details.
Tatsuhiko Miyagawa <miyagawa@bulknews.net>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
This module comes without warranty of any kind.
Convert::RACE, http://www.i-d-n.net/, http://www.i-d-n.net/draft/draft-ietf-idn-dude-02.txt, Unicode::String, Jcode
To install Convert::DUDE, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Convert::DUDE
CPAN shell
perl -MCPAN -e shell install Convert::DUDE
For more information on module installation, please visit the detailed CPAN module installation guide.