Is -C useless?

Paul LeoNerd Evans leonerd at
Fri Sep 12 00:48:06 BST 2008

On Fri, 12 Sep 2008 00:34:15 +0100
ilmari at (Dagfinn Ilmari Mannsåker) wrote:

> You want LC_CTYPE, which can be inherited from LANG or overridden by
> LC_ALL. Also, not all the world is UTF-8.

I could want all sorts of things.

I'm simply pointing out there's no reason why perl can't implement -C by
the time it reads line 1 of the program script. That is not "too late" as
its message would otherwise indicate. My demonstration using binmode
already shows that.

Why can't perl just call binmode itself on STDIN/STDOUT/STDERR by the
time it gets that far, instead of throwing a wobbly and telling me to do
it myself. That doesn't sound very DWIM to me....

And furthermore, binmode / decode_utf8 only get us round the IOE / A
flags respectively. There is, to my knowledge, no perl code that can set
the default UTF-8ness of new filehandles, the way that -Cio does.

And all of this presumes that whoever calls binmode knows how to test the
environment properly. It's come to my attention that this might be more

  binmode STDOUT, ":utf8" if grep m/utf-?8/i, @ENV{qw(LANG LC_MESSAGES LC_ALL)};

And even then I'm not sure it's right. Which really just proves my

The -C...L flag _already_ implements the correct logic. It's just not
useful as it is...

Paul "LeoNerd" Evans

leonerd at
ICQ# 4135350       |  Registered Linux# 179460
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url :

More information about the mailing list