setting binmode for empty filehandle

H

Helmut Richter

In an application, everything is Unicode. I though I would never have to
worry if I set

use utf8; # because the source is also UTF-8
binmode (STDIN, ':utf8');
binmode (STDOUT, ':utf8');
binmode (STDERR, ':utf8');

This would work for explicit usage of these filehandles and for implicit usage
of STDOUT via "print" without a filehandle. It has, however, no effect on <>.

Well between <> there is nothing, why not try

binmode ('', ':utf8');

but that does not help either.

There is an obvious work-around: find myself the command line parameter with
the file name and open it explicitly, or else use STDIN. Possible, but clumsy.

Perhaps, the recommended way of dealing with *all files are Unicode* is
something else. I am open to learn.
 
P

Peter Gordon

In an application, everything is Unicode. I though I would never have
to worry if I set

use utf8; # because the source is also UTF-8
binmode (STDIN, ':utf8');
binmode (STDOUT, ':utf8');
binmode (STDERR, ':utf8');

This would work for explicit usage of these filehandles and for
implicit usage of STDOUT via "print" without a filehandle. It has,
however, no effect on <>.

Well between <> there is nothing, why not try

binmode ('', ':utf8');

but that does not help either.

There is an obvious work-around: find myself the command line
parameter with the file name and open it explicitly, or else use
STDIN. Possible, but clumsy.

Perhaps, the recommended way of dealing with *all files are Unicode*
is something else. I am open to learn.
The below works fir me.

use open ":encoding(UTF-16le)";
binmode(STDOUT, "::encoding(UTF-16le)");
while( <> ) {
 
R

Rainer Weikusat

Helmut Richter said:
In an application, everything is Unicode. I though I would never have to
worry if I set

use utf8; # because the source is also UTF-8
binmode (STDIN, ':utf8');
binmode (STDOUT, ':utf8');
binmode (STDERR, ':utf8');

This would work for explicit usage of these filehandles and for implicit usage
of STDOUT via "print" without a filehandle. It has, however, no effect on <>.

Well between <> there is nothing, why not try

binmode ('', ':utf8');

but that does not help either.

There is an obvious work-around: find myself the command line parameter with
the file name and open it explicitly, or else use STDIN. Possible, but clumsy.

Perhaps, the recommended way of dealing with *all files are Unicode* is
something else.

perl -CDS

could be used achieve the desired effect.
 
G

George Mpouras

use utf8; # because the source is also UTF-8
binmode (STDIN, ':utf8');
binmode (STDOUT, ':utf8');
binmode (STDERR, ':utf8');

this will give double encoding strings
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,813
Messages
2,569,696
Members
45,483
Latest member
TedDvb6626

Latest Threads

Top