Is \r\n considered as two or four characters?

Discussion in 'Java' started by -, Jul 10, 2005.

  1. -

    - Guest

    Is \r\n considered as two or four characters?

    While reading an RFC, it stated that "the maximum length of a message
    shall not exceed 512 characters, including the trailing CR-LF. Thus,
    there are 510 characters allowed for the command and parameters".
    -, Jul 10, 2005
    #1
    1. Advertising

  2. On Sun, 10 Jul 2005 18:33:41 +0800, - wrote:

    > Is \r\n considered as two or four characters?


    Two. You only encode it so the compiler knows you mean the normally
    unprintable character, and replaces it in your string.

    --
    You can't run away forever,
    But there's nothing wrong with getting a good head start.
    --- Jim Steinman, "Rock and Roll Dreams Come Through"
    Stefan Schulz, Jul 10, 2005
    #2
    1. Advertising

  3. "-" <> schreef in bericht
    news:42d0f981$...
    > Is \r\n considered as two or four characters?


    In this case you use four characters to describe two characters.
    Boudewijn Dijkstra, Jul 10, 2005
    #3
  4. - wrote:
    > Is \r\n considered as two or four characters?
    >
    > While reading an RFC, it stated that "the maximum length of a message
    > shall not exceed 512 characters, including the trailing CR-LF. Thus,
    > there are 510 characters allowed for the command and parameters".


    It is considered two characters.
    The backslash escapes the following character (sequence) to have special
    meaning, and to be a single character. Look up character escape
    sequences in about any Java book for more info. Unicode escape sequences
    like \u0035 are also considered a single character but they take six to
    write them.
    --Paul
    Paul Bilnoski, Jul 10, 2005
    #4
  5. On Sun, 10 Jul 2005 18:33:41 +0800, - wrote:

    > Is \r\n considered as two or four characters?
    >
    > While reading an RFC, it stated that "the maximum length of a message
    > shall not exceed 512 characters, including the trailing CR-LF. Thus,
    > there are 510 characters allowed for the command and parameters".


    1459? *grin*

    "\r\n" is encoded as the octet sequence 0D 0A, I believe (that might be
    backwards and I can't be arsed to check) after the escape sequences are
    turned into characters and the characters into ASCII (as per the RFC).

    (You can get away with using UTF-8 instead of ascii without breaking
    existing clients too much.)
    Owen Jacobson, Jul 10, 2005
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Someonekicked
    Replies:
    4
    Views:
    563
    sirclif
    Nov 5, 2004
  2. Hahnemann

    Four or Two Bytes?

    Hahnemann, May 30, 2008, in forum: C Programming
    Replies:
    22
    Views:
    634
    Barry Schwarz
    Jun 2, 2008
  3. Chris “Kwpolska†Warrick

    Re: change spacing to two instead of four with pep8 or flake8?

    Chris “Kwpolska†Warrick, Apr 8, 2014, in forum: Python
    Replies:
    0
    Views:
    42
    Chris “Kwpolska†Warrick
    Apr 8, 2014
  4. Tim Chase
    Replies:
    0
    Views:
    36
    Tim Chase
    Apr 8, 2014
  5. Peter Otten
    Replies:
    2
    Views:
    42
    Peter Otten
    Apr 8, 2014
Loading...

Share This Page