december has asked for the wisdom of the Perl Monks concerning the following question:
Hello Fellow Monks,
I'm have a load of unicode/locale problems (more posts may be forthcoming) on a properly configured Linux system and I'm hoping someone can point out some of the reasons things are not turning out how I want them to turn out.
Observe:
# note: system locale works properly $ LC_CTYPE=fi_FI.UTF-8; export LC_CTYPE # WITH use locale: $ perl -CSA -e 'use utf8; use open ":std", IO => ":utf8"; use locale; +use POSIX qw(locale_h); print "LC_CTYPE: ", setlocale(LC_CTYPE), "\n" +; $str = "säv sov san"; my @arr = $str =~ /\b(\w{3})\b/g; print "", j +oin("|", @arr), "\n";' LC_CTYPE: fi_FI.UTF-8 sov|san # WITHOUT use locale: $ perl -CSA -e 'use utf8; use open ":std", IO => ":utf8"; use POSIX qw +(locale_h); print "LC_CTYPE: ", setlocale(LC_CTYPE), "\n"; $str = "sä +v sov san"; my @arr = $str =~ /\b(\w{3})\b/g; print "", join("|", @ar +r), "\n";' LC_CTYPE: fi_FI.UTF-8 säv|sov|san
... use locale breaks '\w'. It doesn't consider "säv" to be consisting of "word" characters. Since it's a Nordic UTF-8 locale, '\w' should contain "öäå". It works without it, strangely enough.
BTW, even when dropped the -CSA unicode argument to Perl, use open works as expected with both :utf8 and :locale, so Perl does read my locale settings.
What gives?
PS: Perl v5.10.1 on Debian "unstable".
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: use locale broken?
by moritz (Cardinal) on Mar 16, 2011 at 19:20 UTC | |
by december (Pilgrim) on Mar 17, 2011 at 18:13 UTC | |
Re: use locale broken?
by andal (Hermit) on Mar 17, 2011 at 08:53 UTC | |
by december (Pilgrim) on Mar 17, 2011 at 18:01 UTC | |
by ikegami (Patriarch) on Mar 17, 2011 at 19:12 UTC |
Back to
Seekers of Perl Wisdom