Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: lowercasing accented characters

by Anonymous Monk
on Jun 24, 2010 at 01:18 UTC ( [id://846210]=note: print w/replies, xml ) Need Help??


in reply to lowercasing accented characters

Just realized what was wrong.. setting the locale correctly in the first script fixes the problem. The script now looks like:
use strict; use warnings; use locale; use POSIX qw(locale_h); + binmode( STDOUT, ":utf8" ); + setlocale(LC_CTYPE, "german"); + my $accented_char = "\x{00dc}"; #Upper case U with DIAERESIS print "accented char=$accented_char\n"; + my $lowercased = lc( $accented_char ); + print "lowercased=$lowercased\n";
The question I have now however is why I need to set the locale in one case (the script above) but not the other (the second script that reads from stdin in my first post).
According to http://perldoc.perl.org/functions/lc.html, my best guess is that the UTF-8 flag is set on the string when it is read from stdin, but not when the string is instantiated in the code itself. Is there a way to confirm this?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://846210]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (7)
As of 2024-04-24 11:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found