in reply to Re: umlauts, special chars in perl regular expressions
in thread umlauts, special chars in perl regular expressions

how do you make sure a string it's utf-8 encoded?
I tried this and I don't get what I would expect.
my $string = 'e1ņe'; if ($string =~ /^\w+$/) { print "yes"; } else { print "no"; } print "\n"; __OUTPUT___ yes

Replies are listed 'Best First'.
Re: Re: Re: umlauts, special chars in perl regular expressions
by ysth (Canon) on Apr 22, 2004 at 01:50 UTC
    Some of the ways:
    $outstr = $instr; utf8::upgrade($outstr); # or $outstr = Encode::decode("latin-1", $instr); # or add and remove a utf8 character: $outstr = $instr . "\x{100}"; chop $outstr;