Martin J. Evans <[EMAIL PROTECTED]> writes:
>Dan Kogai wrote:
>> On Tuesday, July 1, 2003, at 05:49 PM, Martin J. Evans wrote:
>>
>>> Nick Ing-Simmons wrote:
>>>
>>>> Martin J. Evans <[EMAIL PROTECTED]> writes:
>>>> A socket is a file handle so :
>>>> binmode($sock,":utf8");
>>>> should work.
>> Nick's solution SHOULD BE enough but you should also try:
>>
>> use Encode;
>> # ....
>> print $self->{_socket} encode('utf-8' => $string);
>
>Works.
>
>> or
>>
>> use Encode;
>> # ....
>> print $self->{_socket} encode_utf8($string);
>
>Works.
>
>> or
>> binmode $self->{_socket} => ":encoding(utf8)";
>> # ....
>> print $self->{_socket}
>
>Still generates a warning.
Same reason as binmode($sock,":utf8")
:-(
>
>
>Thanks Dan. Your first two encode solutions work. I know it might be
>pushing it a bit but any ideas why?
Yes. But why have we not discovered this months ago ...
>I pulled the binmode example
>straight from perldoc perluniintro so was surprised when it did not work
Likewise.
>except I had a suspicion that IO::Socket::INET was not returning a file
>handle.
It is.
>I added a Devel::Peek Dump of the $sock and it does not appear
>(to me) to be a handle:
>
>
>SV = RV(0x811e9e8) at 0x8116b30
> REFCNT = 1
> FLAGS = (PADBUSY,PADMY,ROK)
> RV = 0x826aca4
> SV = PVGV(0x8118d88) at 0x826aca4
> REFCNT = 1
> FLAGS = (OBJECT,GMG,SMG)
> IV = 0
> NV = 0
> MAGIC = 0x8118df8
> MG_VIRTUAL = &PL_vtbl_glob
> MG_TYPE = PERL_MAGIC_glob(*)
> MG_OBJ = 0x826aca4
> STASH = 0x8120310 "IO::Socket::INET"
> NAME = "GEN0"
> NAMELEN = 4
> GvSTASH = 0x8127ad4 "Symbol"
> GP = 0x8118dc0
> SV = 0x826acb0
> REFCNT = 1
> IO = 0x826ad10
^^^^^^^^^^^^^^ there is the guts of the handle-ness.
The snag is that sockets have _two_ PerlIO * - hiding in the IO
and binmode only messes with IoIFP but print uses IoOFP
> FORM = 0x0
> AV = 0x0
> HV = 0x826acec
> CV = 0x0
> CVGEN = 0x0
> GPFLAGS = 0x0
> LINE = 94
> FILE = "/usr/local/lib/perl5/5.8.0/Symbol.pm"
> FLAGS = 0x0
> EGV = 0x826aca4 "GEN0"
>
>Thanks again.
>
>Martin
--
Nick Ing-Simmons
http://www.ni-s.u-net.com/