perl-unicode

Re: IO::Socket::INET and utf-8

2003-07-01 07:30:05
Nick Ing-Simmons wrote:
Nick Ing-Simmons <nick(_dot_)ing-simmons(_at_)elixent(_dot_)com> writes:

Martin J. Evans <martin(_at_)easysoft(_dot_)com> writes:

A socket is a file handle so :

binmode($sock,":utf8");

should work.

I'm obviously missing something rather fundamental here.

Not you - us.

How can we have got this far without someone discovering this?

binmmode() works on _input_ side of socket file handle:

  if (!(io = GvIO(gv)) || !(fp = IoIFP(io))) {

  if (PerlIO_binmode(aTHX_ fp,IoTYPE(io),mode_from_discipline(discp),
                     (discp) ? SvPV_nolen(discp) : Nullch)) {

There does not seem to be any way at all of setting layers on output side of a bi-directional socket :-(


Attached patch calls PerlIO_binmode() on IoOFP if it exists and
isn't same as IoIFP. It silences the warning on my quick-check
test.

<patch snipped>

Thanks Nick. The patch worked fine for me against stock 5.8.0 sources (it was 2 lines off but applied fine). The Perl I was working on is distributed as example code so the patch is not too practical for us at the moment. Just to clarify, it is my reading you feel this is a bug in Perl - yes?

Martin

<Prev in Thread] Current Thread [Next in Thread>