Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

unicode in function

by mamut (Sexton)
on Mar 17, 2003 at 06:47 UTC ( #243592=perlquestion: print w/replies, xml ) Need Help??

mamut has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I Have Litle problem under perl 5.8.0 on redhat 8.0.
perl -v This is perl, v5.8.0 built for i386-linux-thread-multi
Ihave litle code which use socket
use Socket 1.3; no utf8; socket(RAW,17, 3, 255) || die $!; #open raw socket my $inetrface=1; #1-lo 2-eth0 3-eth1 #sending raw data to socket this data must by ethernet packet but for +this examle this is irelevant if packet is not valid proble is same w +ith valid packet # ______d_a_t_a_______ send(RAW,"\255\127\255\255\255",0,pack("SniC12",17,0,$interface,0)) || + die "Send :$!\n";
but if I do strace on this program Iget this line which corespondig with sent. Look closer to data on this kernel call there is \302\255 and not plain \255 but ffor \127 is same \127
sendto(3, "\302\255W\302\255\302\255\302\255", 9, 0, {sin_family=AF_PA +CKET, proto=0000, if1, pkttype=0,addr(0)={0, }, 20) = 9
Please help with som workaround or somethin else ??
on perl 5.6.1 this is without problems ! data in perl send a at kernel call sendto is same and raw packet is valid.
Thank's for help

-=- MamuT -=-

Replies are listed 'Best First'.
Re: unicode in function
by jand (Friar) on Mar 17, 2003 at 07:07 UTC
    Redhat 8 by default sets some environment variables to set the default endcoding to UTF8. You can either change your script to call binmode() on the socket handle, or make sure that none of LANG, LANGUAGE, LC_ALL and LC_CTYPE environemtn variable mention UTF8.
Re: unicode in function
by dakkar (Hermit) on Mar 17, 2003 at 11:57 UTC

    Yes, the problem is that Perl is supposing your filehandles should by written to in utf-8, but you want them raw. You should read perldoc -f binmode, and try:

    binmode RAW,':raw';

    -- 
            dakkar - Mobilis in mobile
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://243592]
Approved by Enlil
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2022-06-28 20:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My most frequent journeys are powered by:









    Results (92 votes). Check out past polls.

    Notices?