in reply to Accented letter is not capitalised
The basic rule is that you need to decode your strings before you apply text operations (like uc) to them, and then encode them when you do IO with them (ie print to STDOUT or a file).
It also seems you're coming up with an extra-complicated way of writing ucfirst.
So a piece of code that handles accents in UTF-8 input correctly could look like this:
# make sure that strings coming from STDIN are decoded: binmode STDIN, ':encoding(UTF-8)'; # make sure that strings written to STDOUT are encoded: binmode STDOUT, ':encoding(UTF-8)'; my $line = <STDIN>; $line = ucfirst $line; print $line;
Please read the longer introduction for more background and information.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Accented letter is not capitalised
by Steve_BZ (Chaplain) on Feb 16, 2012 at 20:52 UTC | |
by moritz (Cardinal) on Feb 16, 2012 at 21:07 UTC | |
by tchrist (Pilgrim) on Feb 17, 2012 at 01:04 UTC | |
by Steve_BZ (Chaplain) on Feb 17, 2012 at 16:05 UTC | |
by tchrist (Pilgrim) on Feb 17, 2012 at 20:11 UTC |