perl-diddler has asked for the wisdom of the Perl Monks concerning the following question:
Of course I can easily work-around the problem by adding:
to the beginning of my program, but I'm not sure why it isn't *defaulting*. to UTF-8.binmode STDOUT, ':encoding(UTF-8)'; binmode STDERR, ':encoding(UTF-8)';
I'm running from windows to linux using SecureCRT, which, in its session options, has its 'character encoding' set to UTF-8.
When I log in, if I type locale, I get:
That **looks** like it's saying UTF-8 for a character encoding (this is a Suse11.2 system I'm logging into, BTW, from a Win7 (i.e. unicode supporting) system).LANG=en_US.UTF-8 LC_CTYPE=en_US.UTF-8 LC_NUMERIC="en_US.UTF-8" LC_TIME="en_US.UTF-8" LC_COLLATE="en_US.UTF-8" LC_MONETARY="en_US.UTF-8" LC_MESSAGES="en_US.UTF-8" LC_PAPER="en_US.UTF-8" LC_NAME="en_US.UTF-8" LC_ADDRESS="en_US.UTF-8" LC_TELEPHONE="en_US.UTF-8" LC_LANG=en_US.UTF-8 LC_CTYPE=en_US.UTF-8 LC_NUMERIC="en_US.UTF-8" LC_TIME="en_US.UTF-8" LC_COLLATE="en_US.UTF-8" LC_MONETARY="en_US.UTF-8" LC_MESSAGES="en_US.UTF-8" LC_PAPER="en_US.UTF-8" LC_NAME="en_US.UTF-8" LC_ADDRESS="en_US.UTF-8" LC_TELEPHONE="en_US.UTF-8" LC_MEASUREMENT="en_US.UTF-8" LC_IDENTIFICATION="en_US.UTF-8" LC_ALL=MEASUREMENT="en_US.UTF-8" LC_IDENTIFICATION="en_US.UTF-8" LC_ALL=
So why is perl *defaulting* to STDOUT being non-unicode?
Why do I need the binmode?
Sorry if this is unicode-first-grade, but this stuff looks like it should be so 'simple' -- yet *blech*. I've had other issues when operating on 'internet data' where I've experienced UTF nightmares, since you don't know the character encoding of the website's response until you look at the header -- which I worked around mostly until perl worked itself into a serious coredump about 3,500,000 statements / 70,000 data lines statements into the program (to which some suggested I get to know "perl -d " ... *cough* ...I do, but not um...trying to track that down -- I just shelved the program to wait for a more reliable perl (I did, FWIW, file a bug against Perl, that has yet to be addressed that I know of).
Any idea why perl isn't just 'doing the right thing' as it is so famous for doing? Thanks...
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: why no default unicode?
by moritz (Cardinal) on Mar 19, 2011 at 23:08 UTC | |
by perl-diddler (Chaplain) on Mar 19, 2011 at 23:54 UTC | |
by moritz (Cardinal) on Mar 20, 2011 at 07:24 UTC | |
Re: why no default unicode?
by BrowserUk (Patriarch) on Mar 19, 2011 at 23:16 UTC | |
by perl-diddler (Chaplain) on Mar 20, 2011 at 00:00 UTC | |
by BrowserUk (Patriarch) on Mar 20, 2011 at 00:10 UTC | |
by moritz (Cardinal) on Mar 20, 2011 at 07:27 UTC | |
Re: why no default unicode?
by repellent (Priest) on Mar 20, 2011 at 07:21 UTC | |
Re: why no default unicode?
by Eliya (Vicar) on Mar 19, 2011 at 23:55 UTC |