Re: ucfirst doesn't work if first character of word a special finnish character
by davorg (Chancellor) on Oct 03, 2006 at 10:57 UTC
|
| [reply] |
|
|
Hi!
Yes, have looked at that, but it didn't say much about the locale for Windiws env.
Could you let me know if you have set the locale for windows env?
Thanks,
Taqi Asfar.
| [reply] |
|
|
Sorry, but I've never had to do this on Windows, but as I understand it, it should just work. Are you saying that Windows doesn't support locales?
--
< http://dave.org.uk>
"The first rule of Perl club is you do not talk about
Perl club." -- Chip Salzenberg
| [reply] |
Re: ucfirst doesn't work if first character of word a special finnish character
by Mutant (Priest) on Oct 03, 2006 at 11:32 UTC
|
use locale;
use POSIX qw(locale_h);
setlocale(LC_CTYPE, 'fi_FI');
setlocale(LC_COLLATE, 'fi_FI');
I think this may be somewhat platform dependant, but it works for me. | [reply] [d/l] |
|
|
use locale;
use POSIX qw(locale_h);
setlocale(LC_CTYPE, 'fi_FI');
setlocale(LC_COLLATE, 'fi_FI');
print ucfirst "äbcdef";
-----------
But it prints "-bcdef" i.e "ä" is not being printed correctly.
Do I need to do anything else?
Thanks.
Edited by planetscape - added code tags and rudimentary formatting
| [reply] [d/l] |
|
|
Are you printing directly to STDOUT? It may just be that wherever you're printing it to is unable to display the character correctly.
| [reply] |
|
|
|
|
|
|
Hi!
I tried with this, but still it doesn't work.
----------
use locale;
use POSIX qw(locale_h);
setlocale(LC_CTYPE, 'fi_FI');
setlocale(LC_COLLATE, 'fi_FI');
print ucfirst "äbcdef";
-----------
But it prints "-bcdef" i.e "ä" is not being printed correctly.
Do I need to do anything else? Thanks.
| [reply] |
|
|
Hi! Yes, I am directly printing it to STDOUT. Can't I do that? Thanks,
| [reply] |
Re: ucfirst doesn't work if first character of word a special finnish character
by Koosemose (Pilgrim) on Oct 03, 2006 at 13:36 UTC
|
Yeah windows command prompt (Where most of your output will go) has some issues with anything beyond the standard English characters, thought that could possibly be just an effect of my local being English.
If you're using WinXP, try this:
Go to Control Panel -> Regional and Language options
Click on the "Advanced" Tab
The top section is Labeled "Language for non-Unicode Programs; Click on the dropdown in that section and look for "Finnish" Click on it and hit OK
Just Another Perl Alchemist
| [reply] |
Re: ucfirst doesn't work if first character of word a special finnish character
by ysth (Canon) on Oct 03, 2006 at 16:54 UTC
|
If you can't get locales working, another alternative is to temporarily put your data into perl's internal utf8 encoding, something like:
use Encode qw/encode decode/;
my @strings = ("\xe4ll your chars","\xe5re belong to", "\xf6s");
$_ = encode("iso-8859-15", ucfirst(decode("iso-8859-15",$_))) for @str
+ings;
| [reply] [d/l] |
|
|
There may be a shortcut :) You can save the source file with UTF-8 Encoding (Notepad in Win XP can do this) and then load utf8:
use utf8;
print ucfirst "äbcdef";
And if you can save the source file with a BOM (I'm not sure about Notepad, but Komodo can do this) I think that utf8 pragma will became useless and any unicode character can be used without any extra effort (with Perl 5.8+) | [reply] [d/l] |