Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. how many characters is carriage return? [modified]

how many characters is carriage return? [modified]

Scheduled Pinned Locked Moved C#
questionhelp
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nesfrank
    wrote on last edited by
    #1

    what is the number of characters a carriage returns has? is this the code: \r\n Please help

    modified on Monday, September 29, 2008 1:46 PM

    S G L 3 Replies Last reply
    0
    • N nesfrank

      what is the number of characters a carriage returns has? is this the code: \r\n Please help

      modified on Monday, September 29, 2008 1:46 PM

      S Offline
      S Offline
      Steven Jan
      wrote on last edited by
      #2

      Carriage return is '\r', linefeed is '\n'. Text files on Windows usually end lines with a carriage return and a linefeed character. But to answer your question: a carriage return has 1 character.

      N 1 Reply Last reply
      0
      • S Steven Jan

        Carriage return is '\r', linefeed is '\n'. Text files on Windows usually end lines with a carriage return and a linefeed character. But to answer your question: a carriage return has 1 character.

        N Offline
        N Offline
        nesfrank
        wrote on last edited by
        #3

        what about if it is a free text like this box that we post and we hit enter what is the character?

        1 Reply Last reply
        0
        • N nesfrank

          what is the number of characters a carriage returns has? is this the code: \r\n Please help

          modified on Monday, September 29, 2008 1:46 PM

          G Offline
          G Offline
          Guffa
          wrote on last edited by
          #4

          As Steven said, the carriage return character is a single character. I think that what you actually are looking for is the new line character sequence. A new line sequence can either be one character (line feed) or two characters (carriage return + line feed). A unix/linux based system used a single character, while a DOS/Windows based system uses two characters. In C#, the escape sequence \r gives you the carriage return (CR) character, and the escape sequence \n gives you the line feed (LF) character. To get the new line character sequence for the system that the program is currently running on, use the Environment.NewLine property.

          Despite everything, the person most likely to be fooling you next is yourself.

          L 1 Reply Last reply
          0
          • G Guffa

            As Steven said, the carriage return character is a single character. I think that what you actually are looking for is the new line character sequence. A new line sequence can either be one character (line feed) or two characters (carriage return + line feed). A unix/linux based system used a single character, while a DOS/Windows based system uses two characters. In C#, the escape sequence \r gives you the carriage return (CR) character, and the escape sequence \n gives you the line feed (LF) character. To get the new line character sequence for the system that the program is currently running on, use the Environment.NewLine property.

            Despite everything, the person most likely to be fooling you next is yourself.

            L Offline
            L Offline
            leppie
            wrote on last edited by
            #5

            Environment.NewLine.Length = 2 :sigh:

            xacc.ide - now with TabsToSpaces support
            IronScheme - 1.0 alpha 4a out now (29 May 2008)
            ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))

            G 1 Reply Last reply
            0
            • N nesfrank

              what is the number of characters a carriage returns has? is this the code: \r\n Please help

              modified on Monday, September 29, 2008 1:46 PM

              L Offline
              L Offline
              leppie
              wrote on last edited by
              #6

              2 characters, just as you see them.

              xacc.ide - now with TabsToSpaces support
              IronScheme - 1.0 alpha 4a out now (29 May 2008)
              ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))

              1 Reply Last reply
              0
              • L leppie

                Environment.NewLine.Length = 2 :sigh:

                xacc.ide - now with TabsToSpaces support
                IronScheme - 1.0 alpha 4a out now (29 May 2008)
                ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))

                G Offline
                G Offline
                Guffa
                wrote on last edited by
                #7

                leppie wrote:

                Environment.NewLine.Length = 2

                Yes, in Microsoft's implementation of the CLR. If you run the same program in Mono on Linux, the length is one. :)

                Despite everything, the person most likely to be fooling you next is yourself.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups