Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^2: ISO 8859-1 characters and \w \b etc.

by dpavlin (Friar)
on Jun 27, 2004 at 22:20 UTC ( [id://370054]=note: print w/replies, xml ) Need Help??


in reply to Re: ISO 8859-1 characters and \w \b etc.
in thread ISO 8859-1 characters and \w \b etc.

I know that this node is somewhat duplicate of things said above, but as a ISO-8859-2 user, I would like to emphasize that you will need to setup LC_CTYPE and use locale. You should also consider setuping LC_COLLATE so that sort also uses locale.

You will have to have locale installed on your system. Try setting enviroment variables and running perl -v to see if perl picks up locale (it will complain if it doesn't).

Having said that, locale setup is done per language and country (that's why locale for Croatia is hr_HR and for USA en_US). You might also use locale aliases (defined in /usr/lib/X11/locale/locale.alias).

It might be enough just to add use locale; in your code. If you need. Example follows (for Croatia with it's funny accented characters; we use ISO-8859-2, but principle is the same).

#!/usr/bin/perl -w use strict; use locale; use POSIX qw(locale_h); setlocale(LC_CTYPE, 'hr_HR'); setlocale(LC_COLLATE, 'hr_HR'); my $text = "foo čevapčić bar"; print join(", ",sort split(/\W/,$text)),"\n";
If you are not bothered with changing system-wide locale, you can also setup your /etc/profile and apache's httpd.conf with enviroment variables and drop setlocale from code.
2share!2flame...

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (7)
As of 2024-06-21 20:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.