Thread Zu perlfaq: "How can I make \w match national character sets?"
(10 answers)
Opened by Gast at 2009-10-17 18:05
Hat funktioniert:
Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 #!/usr/bin/perl -w use 5.010; use strict; use utf8; use Encode qw( encode ); my $string = 'abcäöüß'; my @match = $string =~ /(\w)/g; say encode( 'utf-8', "@match" ); # a b c ä ö ü ß Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 #!/usr/bin/perl -w use 5.010; use strict; use locale; # de_DE.UTF-8 use utf8; use Encode qw( encode ); my $string = 'abcäöüß'; my @match = $string =~ /([[:word:]])/g; say encode( 'utf8', "@match" ); # a b c ä ö ü ß Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 #!/usr/bin/perl -w use 5.010; use strict; use utf8; use locale; use POSIX qw( locale_h ); use Encode qw( encode ); my $latin_locale = setlocale( LC_CTYPE, 'de_DE.ISO8859-1' ); my $string = 'abcäöüß'; my @match = $string =~ /(\w)/g; say encode( 'utf-8', "@match" ); # a b c ä ö ü ß Habe ich richtig geraten: beim letzten Beispiel muß ich mit utf-8 encoden, weil setlocale sich nicht auf meine Konsole auswirkt und diese auf utf8 eingestellt ist? View full thread Zu perlfaq: "How can I make \w match national character sets?" |