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".


In reply to use locale broken? by december

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.