How to 'textualize' a buffer

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Udi

    How to 'textualize' a buffer

    Hi All,
    I'm looking for a way to convert a buffer into text (represent buffer
    as text).
    The text is read by a parser that needs to cut it at a special
    character that is not part of the buffer (E.g.end of line).
    (I think this is similar to the method used to 'textualize' binary
    data in HTML (to display special characters?) )

    For exapmle:
    A parser parses the following command line to invoke the function
    "Foo" with the relevant parameter
    (Command line is all text) :
    "Foo(xxx)\n "

    Now, I need to receive the same command line with the argument
    represented in binary and not in text, and still be able to parse it.

    Is there a .Net Class that knows to represent binary in a text format?
    Thanks,
    Udi.

  • DeveloperX

    #2
    Re: How to 'textualize' a buffer

    On 5 Mar, 15:56, "Udi" <UdiBenSen...@g mail.comwrote:
    Hi All,
    I'm looking for a way to convert a buffer into text (represent buffer
    as text).
    The text is read by a parser that needs to cut it at a special
    character that is not part of the buffer (E.g.end of line).
    (I think this is similar to the method used to 'textualize' binary
    data in HTML (to display special characters?) )
    >
    For exapmle:
    A parser parses the following command line to invoke the function
    "Foo" with the relevant parameter
    (Command line is all text) :
    "Foo(xxx)\n "
    >
    Now, I need to receive the same command line with the argument
    represented in binary and not in text, and still be able to parse it.
    >
    Is there a .Net Class that knows to represent binary in a text format?
    Thanks,
    Udi.
    Would this help?

    //First working on a real string
    byte[] b;
    string s3;
    System.Text.ASC IIEncoding en = new System.Text.ASC IIEncoding();
    b = en.GetBytes("Th is is a test2\n".ToChar Array());
    s3 = en.GetString(b) ;
    Console.WriteLi ne(s3);

    //now working on non printables.
    b = new byte[] {1,2,3,4,5,6,7, 255,9,10};
    s3 = en.GetString(b) ;
    Console.WriteLi ne(s3);

    Comment

    • Udi

      #3
      Re: How to 'textualize' a buffer

      On Mar 5, 6:29 pm, "DeveloperX " <nntp...@operam ail.comwrote:
      On 5 Mar, 15:56, "Udi" <UdiBenSen...@g mail.comwrote:
      >
      >
      >
      >
      >
      Hi All,
      I'm looking for a way to convert a buffer into text (represent buffer
      as text).
      The text is read by a parser that needs to cut it at a special
      character that is not part of the buffer (E.g.end of line).
      (I think this is similar to the method used to 'textualize' binary
      data in HTML (to display special characters?) )
      >
      For exapmle:
      A parser parses the following command line to invoke the function
      "Foo" with the relevant parameter
      (Command line is all text) :
      "Foo(xxx)\n "
      >
      Now, I need to receive the same command line with the argument
      represented in binary and not in text, and still be able to parse it.
      >
      Is there a .Net Class that knows to represent binary in a text format?
      Thanks,
      Udi.
      >
      Would this help?
      >
      //First working on a real string
      byte[] b;
      string s3;
      System.Text.ASC IIEncoding en = new System.Text.ASC IIEncoding();
      b = en.GetBytes("Th is is a test2\n".ToChar Array());
      s3 = en.GetString(b) ;
      Console.WriteLi ne(s3);
      >
      //now working on non printables.
      b = new byte[] {1,2,3,4,5,6,7, 255,9,10};
      s3 = en.GetString(b) ;
      Console.WriteLi ne(s3);- Hide quoted text -
      >
      - Show quoted text -
      I don't know.
      What would happen if one of the bytes in b has the value of '\n'?
      How will this be represented in s3?
      I'll test it.
      Thanks. :)

      Comment

      • Udi

        #4
        Re: How to 'textualize' a buffer

        On Mar 5, 6:29 pm, "DeveloperX " <nntp...@operam ail.comwrote:
        On 5 Mar, 15:56, "Udi" <UdiBenSen...@g mail.comwrote:
        >
        >
        >
        >
        >
        Hi All,
        I'm looking for a way to convert a buffer into text (represent buffer
        as text).
        The text is read by a parser that needs to cut it at a special
        character that is not part of the buffer (E.g.end of line).
        (I think this is similar to the method used to 'textualize' binary
        data in HTML (to display special characters?) )
        >
        For exapmle:
        A parser parses the following command line to invoke the function
        "Foo" with the relevant parameter
        (Command line is all text) :
        "Foo(xxx)\n "
        >
        Now, I need to receive the same command line with the argument
        represented in binary and not in text, and still be able to parse it.
        >
        Is there a .Net Class that knows to represent binary in a text format?
        Thanks,
        Udi.
        >
        Would this help?
        >
        //First working on a real string
        byte[] b;
        string s3;
        System.Text.ASC IIEncoding en = new System.Text.ASC IIEncoding();
        b = en.GetBytes("Th is is a test2\n".ToChar Array());
        s3 = en.GetString(b) ;
        Console.WriteLi ne(s3);
        >
        //now working on non printables.
        b = new byte[] {1,2,3,4,5,6,7, 255,9,10};
        s3 = en.GetString(b) ;
        Console.WriteLi ne(s3);- Hide quoted text -
        >
        - Show quoted text -
        No. This won't help. I tested it and the last byte in b (10) is
        displayed as '\n', and this is what I need to prevent.
        Isn't there any class that would change it to something like ' '
        just like it is done done with HTMLs?

        Comment

        • DeveloperX

          #5
          Re: How to 'textualize' a buffer

          On 6 Mar, 07:46, "Udi" <UdiBenSen...@g mail.comwrote:
          On Mar 5, 6:29 pm, "DeveloperX " <nntp...@operam ail.comwrote:
          >
          >
          >
          >
          >
          On 5 Mar, 15:56, "Udi" <UdiBenSen...@g mail.comwrote:
          >
          Hi All,
          I'm looking for a way to convert a buffer into text (represent buffer
          as text).
          The text is read by a parser that needs to cut it at a special
          character that is not part of the buffer (E.g.end of line).
          (I think this is similar to the method used to 'textualize' binary
          data in HTML (to display special characters?) )
          >
          For exapmle:
          A parser parses the following command line to invoke the function
          "Foo" with the relevant parameter
          (Command line is all text) :
          "Foo(xxx)\n "
          >
          Now, I need to receive the same command line with the argument
          represented in binary and not in text, and still be able to parse it.
          >
          Is there a .Net Class that knows to represent binary in a text format?
          Thanks,
          Udi.
          >
          Would this help?
          >
          //First working on a real string
          byte[] b;
          string s3;
          System.Text.ASC IIEncoding en = new System.Text.ASC IIEncoding();
          b = en.GetBytes("Th is is a test2\n".ToChar Array());
          s3 = en.GetString(b) ;
          Console.WriteLi ne(s3);
          >
          //now working on non printables.
          b = new byte[] {1,2,3,4,5,6,7, 255,9,10};
          s3 = en.GetString(b) ;
          Console.WriteLi ne(s3);- Hide quoted text -
          >
          - Show quoted text -
          >
          No. This won't help. I tested it and the last byte in b (10) is
          displayed as '\n', and this is what I need to prevent.
          Isn't there any class that would change it to something like ' '
          just like it is done done with HTMLs?- Hide quoted text -
          >
          - Show quoted text -
          Well \n is 10, can you give a slightly bigger example? I'm sure I'm
          missing something.

          Comment

          Working...