in reply to Re^5: Date::Manip and German months names (solved)
in thread Date::Manip and German months names

Sounds like you forgot to use utf8::upgrade($from);

No, I tried this:

#!/usr/bin/perl $Lang{$L}{"Repl"} = { "m" => "Monat" }; # mimic Date::Manip $_ = "Mär"; print "before: $_\n"; foreach $from (keys %{ $Lang{$L}{"Repl"} }) { $to=$Lang{$L}{"Repl"}{$from}; utf8::upgrade($from); # Use Unicode semantics s/(^|[^[:alpha:]])$from($|[^[:alpha:]])/$1$to$2/i; } print "after: $_\n";

which prints

before: Mär after: Monatär

Using

s/(^|[^\p{IsAlpha}])$from($|[^\p{IsAlpha}])/$1$to$2/i;

in place of the above substitution does work fine, though (as does adding use locale to the [:alpha:] version):

before: Mär after: Mär

presuming other changes will be made as well
No, using unicode semantics is enough.

I was referring to "MÄR" also working (in addition to "Mär") in the context of Date::Manip...  which it won't unless that abbreviation is also being set up in the respective $$d{"month_abb"}=...

Replies are listed 'Best First'.
Re^7: Date::Manip and German months names (solved)
by ikegami (Patriarch) on Jul 10, 2008 at 01:38 UTC

    Interesting. I would have thought that promoting the regexp would have been enough. Anyway, the fix to promote the string on which s/// acts. Change
    utf8::upgrade($from);  # Use Unicode semantics
    to
    utf8::upgrade($_);  # Use Unicode semantics