locale problem with P::RD
[email protected] (Karl Gaissmaier) Wed, 14 Jul 2004 22:24:23 +0200
| Newsgroups | perl.recdescent |
|---|---|
| Message-ID | <[email protected]> |
Hi,
I nearly finished Config::Scoped, yet another config
file parser but I am currently busy with an annoying
locale problem. I'm for example not able to match
german umlaute with the rule pattern /\w/ even with
the proper LC_... env and 'use locale' in P::RD.
With a plain pattern match 'string' =~ /\w+/ it's working!
Please check my stripped down code snippet:
#-------- locale_test.pl --------------------
use locale;
use Parse::RecDescent;
$grammar = 'char : /\w/ {print "P::RD $item[1] matched\n"}';
Parse::RecDescent->new($grammar)->char('ä')
or warn "P::RD ä didn't match\n";
Parse::RecDescent->new($grammar)->char('a')
or warn "P::RD a didn't match\n";
# and now with plain regexp
'ä' =~ /\w/ ? print "/\\w/ ä matched\n"
: warn "/\\w/ ä didn't match\n";
'a' =~ /\w/ ? print "/\\w/ a matched\n"
: warn "/\\w/ a didn't match\n";
exit 0;
#----------------------------------------------
and with the proper LC_CTYPE set:
wega$ LC_CTYPE=iso_8859_1 perl locale_test.pl
P::RD ä didn't match
P::RD a matched
/w/ ä matched
/w/ a matched
you see, with /\w/ we match the german umlaut 'ä'
but not as a pattern literal in P::RD.
And for completeness:
=====================
This is perl, v5.8.4 built for sun4-solaris
P::RD::VERSION = '1.94'
wega$ locale -a
POSIX
C
iso_8859_1
Any hints welcome, perhaps I don't see the wood
for the trees.
Best Regards
Charly
--
Karl Gaissmaier KIZ/Infrastructure, University of Ulm, Germany
Email:[email protected] Service Group Network