I was able to test on 5.8.7 (an old freebsd box), as well as 5.10.1 (linux) and 5.12.3 (macosx), and all three behaved the same -- including a problem in the output from Test::More::is() (I don't know why unicode characters get converted to "?").

Here's my "util.pm":

use strict; package util; sub beautify { my ($in) = @_; my $tmp; foreach (split(/\s/o, lc($in))){ $tmp .= ucfirst($_); $tmp .= ' '; } $tmp =~ s/\s$//; return($tmp); } 1;
Here's my test code:
use utf8; use util; use Test::More tests => 4; is( &util::beautify( "àisTheWord"), "Àistheword", "àisTheWord - specia +l character changes case." ); is( &util::beautify( "ùisTheWord"), "Ùistheword", "ùisTheWord - specia +l character changes case." ); is( &util::beautify( "üisTheWord"), "Üistheword", "üisTheWord - specia +l character changes case." ); is( &util::beautify( "ÿisTheWord"), "Ÿistheword", "ÿisTheWord - specia +l character changes case." ); print util::beautify( "ÿisTheWord") . "\n";
And here's the output I got on all three versions:
1..4 ok 1 - ?isTheWord - special character changes case. ok 2 - ?isTheWord - special character changes case. ok 3 - ?isTheWord - special character changes case. ok 4 - ?isTheWord - special character changes case. Ÿistheword
(I put in that last print statement just to check that it would correctly show what was expected on a utf8-capable terminal. I also left out the "u with circumflex because for some reason I couldn't post its upper-case form correctly -- very strange.)

UPDATE: I should add that the command line I used was "perl -C31 test-util.t" (and it seems "-CS" would do the same thing.) Anyway, the tests do pass for me, despite the test message getting munged. So what are you doing that's different?

SECOND UPDATE: I added use Test::More::UTF8 as per mje's suggestion below, and that fixed the output messages -- thanks++!!


In reply to Re: UTF8 - ucfirst() is not working with foreign characters by graff
in thread UTF8 - ucfirst() is not working with foreign characters by tyatpi

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.