it
perl -CO -E 'say "\N{U+00E1}"'
prints
รก
How to achieve to get the same thing with the following:
echo "U+00E1" | perl -CO -lnE 'say what_here($_)'
Use charnames :
echo "U+00E1" | perl -Mcharnames=short -CO -lnE 'say charnames::vianame($_)'
You can also use eval if you can control what comes in as input:
eval
echo "U+00E1" | perl -CO -lnE 'say eval qq("\\N{$_}")'
Pure basic Perl solution:
echo "U+00E1" | perl -C -nE 'say chr(hex) if s/U\+//'
Please don't use unsafe ( eval ) solutions like:
echo "U+00E1" | perl -C -nE 's/U\+/0x/;eval qq{say chr($_)}'
Using pack
pack
echo U+0041 U+0042 U+0043 U+00E1 | perl -ne"print pack 'U', hex for /\p{hex}+/g"
ABCรก
echo "U+00E1" | perl -CO -lnE 'eval "\$a=\"\\N{$_}\";"; say $a;'