Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Re: Cross Platform end of Line characters

by liz (Monsignor)
on Aug 02, 2003 at 15:06 UTC ( #280287=note: print w/replies, xml ) Need Help??


in reply to Re: Cross Platform end of Line characters
in thread Cross Platform end of Line characters

Hmmm...

From perlport:

       A common misconception in socket programming is that "\n"
       eq "\012" everywhere.  When using protocols such as common
       Internet protocols, "\012" and "\015" are called for
       specifically, and the values of the logical "\n" and "\r"
       (carriage return) are not reliable.

           print SOCKET "Hi there, client!\r\n";      # WRONG
           print SOCKET "Hi there, client!\015\012";  # RIGHT
Doesn't that apply here as well? Or only if you want to make sure you're script has to be super portable?

Liz

  • Comment on Re: Re: Cross Platform end of Line characters

Replies are listed 'Best First'.
Re: Re: Re: Cross Platform end of Line characters
by Cine (Friar) on Aug 02, 2003 at 15:55 UTC
    Well, yes and no. Mac, Win and Linux all use ASCII, which defines \n to be \012, if the document in question is in a non-ascii format, then a larger conversion than just lineends are probably needed anyway...

    T I M T O W T D I

      The ASCII table has no concecpt of '\n', that's from the C programming language.

      ASCII defines linefeed as \012.

      Unix uses a linefeed as the line terminator in text files, C denoted the linefeed, or new line code as \n. But when Unix was ported to other platforms, it became increasingly important to handle text files from other platforms, with different line terminator / line separator sequencecs.

      --
      TTTATCGGTCGTTATATAGATGTTTGCA

Re: Re: Re: Cross Platform end of Line characters
by djbiv (Scribe) on Aug 03, 2003 at 13:10 UTC
    From my experience writing a client / server application on Win2000 and AIX, your much beeter off using syswrite and sysread to communicate over the socket. This way you don't need to worry about the \n or \r when you transfer your data over the socket using print.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2022-12-02 12:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?