Hi,
I'm trying to translate some special characters into unicoded Greek.
#This works:
use charnames ':full';
print("\N{GREEK SMALL LETTER EPSILON}\n");
#But this doesn't:
use charnames ':full';
$var = 'GREEK SMALL LETTER EPSILON';
print("\N{$var}\n");
It gives this error:
Unknown charname '$var' at C:/Perl/lib/charnames.pm line 32.
Propagated at un.pl line 3, within string
Execution of un.pl aborted due to compilation errors.
shell returned 255
I need to pass the character name at runtime. But I see in the manpages that \N does not accept a variable. Nor does \x, it seems. The manpages suggest using charnames::vianame(), but all that does is return a character code, whereas I'm interested in getting back the actual unicoded character. Can anyone suggest a solution?
Many thanks.
Casey
Re: unicode, \N, \x, character encoding
\N escapes are seen pre-interpolation. I suggest
chr(charnames::vianame($name)).
Re^2: unicode, \N, \x, character encoding
Hi Jeff,
It worked! Your help is greatly appreciated.
:-)
Casey
Re: unicode, \N, \x, character encoding