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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Encoding.ASCII.GetString(byte[]) and CR LF

Encoding.ASCII.GetString(byte[]) and CR LF

Scheduled Pinned Locked Moved C#
question
3 Posts 2 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.
  • T Offline
    T Offline
    TMattC
    wrote on last edited by
    #1

    Could someone please explain to me what´s going on in this conversion. I dont understand the result.

    byte[] arr = new byte[6] { 68, 65, 84, 65, 13, 10 };
    string str = Encoding.ASCII.GetString(arr);

    According to the ASCII table the bytes mean DATA\n\t. (13=CR='\n', 10=LF='\r') But the string receives DATA\t\n :confused:!?! If I change their places { 68, 65, 84, 65, 10, 13 } the string receives DATA\n\t. Why does the CR and LF change place? Im really confused here.

    Richard Andrew x64R 1 Reply Last reply
    0
    • T TMattC

      Could someone please explain to me what´s going on in this conversion. I dont understand the result.

      byte[] arr = new byte[6] { 68, 65, 84, 65, 13, 10 };
      string str = Encoding.ASCII.GetString(arr);

      According to the ASCII table the bytes mean DATA\n\t. (13=CR='\n', 10=LF='\r') But the string receives DATA\t\n :confused:!?! If I change their places { 68, 65, 84, 65, 10, 13 } the string receives DATA\n\t. Why does the CR and LF change place? Im really confused here.

      Richard Andrew x64R Offline
      Richard Andrew x64R Offline
      Richard Andrew x64
      wrote on last edited by
      #2

      You have the nomenclature a little mixed up: CR = 13 = '\r' LF = 10 = '\n' TAB = 9 = '\t'

      The difficult we do right away... ...the impossible takes slightly longer.

      T 1 Reply Last reply
      0
      • Richard Andrew x64R Richard Andrew x64

        You have the nomenclature a little mixed up: CR = 13 = '\r' LF = 10 = '\n' TAB = 9 = '\t'

        The difficult we do right away... ...the impossible takes slightly longer.

        T Offline
        T Offline
        TMattC
        wrote on last edited by
        #3

        Thankyou! Thought I was getting insane.

        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