<P>The mechanism of translation of <CODE>\N{...}</CODE> escapes is general and not
hardwired into <EM>charnames.pm</EM>. A module can install custom
translations (inside the scope which <A HREF="../lib/Pod/perlfunc.html#item_use"><CODE>use</CODE></A>s the module) with the
following magic incantation:</P>
<PRE>
use charnames (); # for $charnames::hint_bits
sub import {
shift;
$^H |= $charnames::hint_bits;
$^H{charnames} = \&translator;
}</PRE>
<P>Here <CODE>translator()</CODE> is a subroutine which takes <CODE>CHARNAME</CODE> as an
argument, and returns text to insert into the string instead of the
<CODE>\N{CHARNAME}</CODE> escape. Since the text to insert should be different
in <CODE>bytes</CODE> mode and out of it, the function should check the current
state of <CODE>bytes</CODE>-flag as in:</P>
<PRE>
use bytes (); # for $bytes::hint_bits
sub translator {
if ($^H & $bytes::hint_bits) {
return bytes_translator(@_);
}
else {
return utf8_translator(@_);
}
}</PRE>
<P>
<HR>
<H1><A NAME="bugs">BUGS</A></H1>
<P>Since evaluation of the translation function happens in a middle of
compilation (of a string literal), the translation function should not
do any <A HREF="../lib/Pod/perlfunc.html#item_eval"><CODE>eval</CODE></A>s or <A HREF="../lib/Pod/perlfunc.html#item_require"><CODE>require</CODE></A>s. This restriction should be lifted in