line feed and tab

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

    line feed and tab

    I have a C# app that I am writing which is going to insert text into a
    table, which is then picked up by another program and emailed. On the text
    version of the email (when the user doesn't have html email), I need to put
    tabs in between columns of data and then line feeds after each row. How can
    I do this? Right now I'm doing "\t" for tab and "\r\n" for line feed, but
    when I generate the text, those characters actually come out in the text.

    Please help.
    Mark


  • Alex Bendig

    #2
    Re: line feed and tab

    Mark,

    Instead of escape sequences you could also use explicit type casting.
    To insert a horizontal tab, you would then simply use (char) 9

    Hope this helps.

    Regards,
    Alex

    "Mark" <maxmann@kc.rr. com> wrote in message
    news:em7rneiSDH A.3088@TK2MSFTN GP10.phx.gbl...[color=blue]
    > I have a C# app that I am writing which is going to insert text into a
    > table, which is then picked up by another program and emailed. On the[/color]
    text[color=blue]
    > version of the email (when the user doesn't have html email), I need to[/color]
    put[color=blue]
    > tabs in between columns of data and then line feeds after each row. How[/color]
    can[color=blue]
    > I do this? Right now I'm doing "\t" for tab and "\r\n" for line feed, but
    > when I generate the text, those characters actually come out in the text.
    >
    > Please help.
    > Mark
    >
    >[/color]


    Comment

    • Mark

      #3
      Re: line feed and tab

      I tried this and it still comes out with the "\t" in the string.

      "Alex Bendig" <a.bendig@ieee. org> wrote in message
      news:beuqk2$95q $1@newsserver.r rzn.uni-hannover.de...[color=blue]
      > Mark,
      >
      > Instead of escape sequences you could also use explicit type casting.
      > To insert a horizontal tab, you would then simply use (char) 9
      >
      > Hope this helps.
      >
      > Regards,
      > Alex
      >
      > "Mark" <maxmann@kc.rr. com> wrote in message
      > news:em7rneiSDH A.3088@TK2MSFTN GP10.phx.gbl...[color=green]
      > > I have a C# app that I am writing which is going to insert text into a
      > > table, which is then picked up by another program and emailed. On the[/color]
      > text[color=green]
      > > version of the email (when the user doesn't have html email), I need to[/color]
      > put[color=green]
      > > tabs in between columns of data and then line feeds after each row. How[/color]
      > can[color=green]
      > > I do this? Right now I'm doing "\t" for tab and "\r\n" for line feed,[/color][/color]
      but[color=blue][color=green]
      > > when I generate the text, those characters actually come out in the[/color][/color]
      text.[color=blue][color=green]
      > >
      > > Please help.
      > > Mark
      > >
      > >[/color]
      >
      >[/color]


      Comment

      • Alex Bendig

        #4
        Re: line feed and tab

        Could you show some code for the portion where you generate your text
        version of the email? One way could certainly be to substitute the verbatim
        escape sequences with the appropriate formatting characters.

        "Mark" <maxmann@kc.rr. com> wrote in message
        news:uTFvaZjSDH A.3144@tk2msftn gp13.phx.gbl...[color=blue]
        > I tried this and it still comes out with the "\t" in the string.
        >
        > "Alex Bendig" <a.bendig@ieee. org> wrote in message
        > news:beuqk2$95q $1@newsserver.r rzn.uni-hannover.de...[color=green]
        > > Mark,
        > >
        > > Instead of escape sequences you could also use explicit type casting.
        > > To insert a horizontal tab, you would then simply use (char) 9
        > >
        > > Hope this helps.
        > >
        > > Regards,
        > > Alex
        > >
        > > "Mark" <maxmann@kc.rr. com> wrote in message
        > > news:em7rneiSDH A.3088@TK2MSFTN GP10.phx.gbl...[color=darkred]
        > > > I have a C# app that I am writing which is going to insert text into a
        > > > table, which is then picked up by another program and emailed. On the[/color]
        > > text[color=darkred]
        > > > version of the email (when the user doesn't have html email), I need[/color][/color][/color]
        to[color=blue][color=green]
        > > put[color=darkred]
        > > > tabs in between columns of data and then line feeds after each row.[/color][/color][/color]
        How[color=blue][color=green]
        > > can[color=darkred]
        > > > I do this? Right now I'm doing "\t" for tab and "\r\n" for line feed,[/color][/color]
        > but[color=green][color=darkred]
        > > > when I generate the text, those characters actually come out in the[/color][/color]
        > text.[color=green][color=darkred]
        > > >
        > > > Please help.
        > > > Mark
        > > >
        > > >[/color]
        > >
        > >[/color]
        >
        >[/color]


        Comment

        • Mark

          #5
          Re: line feed and tab

          Okay, I've tried it both of these ways and get the same result.

          string strText="Proper ty Name" + (char)9 + "Address" + (char)9 +
          "City/State/Zip";
          OR
          string strText="Proper ty Name" + "\t" + "Address" + "\t" + "City/State/Zip";



          "Alex Bendig" <a.bendig@ieee. org> wrote in message
          news:beuubm$a08 $1@newsserver.r rzn.uni-hannover.de...[color=blue]
          > Could you show some code for the portion where you generate your text
          > version of the email? One way could certainly be to substitute the[/color]
          verbatim[color=blue]
          > escape sequences with the appropriate formatting characters.
          >
          > "Mark" <maxmann@kc.rr. com> wrote in message
          > news:uTFvaZjSDH A.3144@tk2msftn gp13.phx.gbl...[color=green]
          > > I tried this and it still comes out with the "\t" in the string.
          > >
          > > "Alex Bendig" <a.bendig@ieee. org> wrote in message
          > > news:beuqk2$95q $1@newsserver.r rzn.uni-hannover.de...[color=darkred]
          > > > Mark,
          > > >
          > > > Instead of escape sequences you could also use explicit type casting.
          > > > To insert a horizontal tab, you would then simply use (char) 9
          > > >
          > > > Hope this helps.
          > > >
          > > > Regards,
          > > > Alex
          > > >
          > > > "Mark" <maxmann@kc.rr. com> wrote in message
          > > > news:em7rneiSDH A.3088@TK2MSFTN GP10.phx.gbl...
          > > > > I have a C# app that I am writing which is going to insert text into[/color][/color][/color]
          a[color=blue][color=green][color=darkred]
          > > > > table, which is then picked up by another program and emailed. On[/color][/color][/color]
          the[color=blue][color=green][color=darkred]
          > > > text
          > > > > version of the email (when the user doesn't have html email), I need[/color][/color]
          > to[color=green][color=darkred]
          > > > put
          > > > > tabs in between columns of data and then line feeds after each row.[/color][/color]
          > How[color=green][color=darkred]
          > > > can
          > > > > I do this? Right now I'm doing "\t" for tab and "\r\n" for line[/color][/color][/color]
          feed,[color=blue][color=green]
          > > but[color=darkred]
          > > > > when I generate the text, those characters actually come out in the[/color]
          > > text.[color=darkred]
          > > > >
          > > > > Please help.
          > > > > Mark
          > > > >
          > > > >
          > > >
          > > >[/color]
          > >
          > >[/color]
          >
          >[/color]


          Comment

          • Dan Ferguson

            #6
            Re: line feed and tab

            Mark,

            Escape sequences are only interpreted when doing some sort or "Formatted"
            operation such as writing to the Console or a file, or in the case of the
            StringBuilder, AppendFormat().

            To insert formatting characters into a string, try the following:
            StringBuilder sb = new StringBuilder() ;

            sb.Append("Text ...");

            sb.AppendFormat ("\t\t");

            sb.Append("More Text");

            sb.AppendFormat ("\r\n");

            sb.Append("New Line");

            Console.WriteLi ne( sb.ToString () );

            Dan




            "Mark" <maxmann@kc.rr. com> wrote in message
            news:em7rneiSDH A.3088@TK2MSFTN GP10.phx.gbl...[color=blue]
            > I have a C# app that I am writing which is going to insert text into a
            > table, which is then picked up by another program and emailed. On the[/color]
            text[color=blue]
            > version of the email (when the user doesn't have html email), I need to[/color]
            put[color=blue]
            > tabs in between columns of data and then line feeds after each row. How[/color]
            can[color=blue]
            > I do this? Right now I'm doing "\t" for tab and "\r\n" for line feed, but
            > when I generate the text, those characters actually come out in the text.
            >
            > Please help.
            > Mark
            >
            >[/color]


            Comment

            Working...