String processing bug in .net 2?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • greg.merideth@gmail.com

    String processing bug in .net 2?

    There's an automated email an application generates, that we've found a
    wierd processing bug(?) with in .net 2.0

    The app has the following lines. There are 20 lines above that use
    "\n\r" that wrap just fine:

    [20] message.Body += "EONE\n\r";
    [21] message.Body += "Name [{0}] Reg# [{1}] Owner [{2}]\n\r";
    [22] message.Body += "Associatio n [{1}] ADOwner [{4}] \n\r";

    and then mails the message. The wierd part is line 20 processes the
    "\n\r" and wraps the line however, the "\n\r" are ignored on lines 21
    and 22. The line comes out in a single continuous line. The [(0)]'s
    need to be in there for an application to process the message. If I
    remove the [(0)]'s the line wraps! Putting them back in the lines does
    not wrap.

    What would c# be doing with the "[(0)]" as it shouldn't try to process
    them. With the [(0)] it doesn't process the "\n\r" and without the
    [(0)] it works fine. Wierd eh?

  • Steven Nagy

    #2
    Re: String processing bug in .net 2?

    Maybe its something that is being fed into those place holders later on
    that is screwing it up?
    Does it also happen if you use Environment.New Line instead?
    Is the email message HTML ? Could you use <br> instead to get around
    your problem?
    When the line doesn't wrap, does it actually print the \n\r?

    Comment

    • Michael C

      #3
      Re: String processing bug in .net 2?

      <greg.merideth@ gmail.com> wrote in message
      news:1138163512 .086648.35070@f 14g2000cwb.goog legroups.com...[color=blue]
      > There's an automated email an application generates, that we've found a
      > wierd processing bug(?) with in .net 2.0
      >
      > The app has the following lines. There are 20 lines above that use
      > "\n\r" that wrap just fine:[/color]

      Shouldn't that be \r\n?

      Michael


      Comment

      • Jon Skeet [C# MVP]

        #4
        Re: String processing bug in .net 2?

        greg.merideth@g mail.com <greg.merideth@ gmail.com> wrote:[color=blue]
        > There's an automated email an application generates, that we've found a
        > wierd processing bug(?) with in .net 2.0
        >
        > The app has the following lines. There are 20 lines above that use
        > "\n\r" that wrap just fine:
        >
        > [20] message.Body += "EONE\n\r";
        > [21] message.Body += "Name [{0}] Reg# [{1}] Owner [{2}]\n\r";
        > [22] message.Body += "Associatio n [{1}] ADOwner [{4}] \n\r";
        >
        > and then mails the message. The wierd part is line 20 processes the
        > "\n\r" and wraps the line however, the "\n\r" are ignored on lines 21
        > and 22. The line comes out in a single continuous line. The [(0)]'s
        > need to be in there for an application to process the message. If I
        > remove the [(0)]'s the line wraps! Putting them back in the lines does
        > not wrap.
        >
        > What would c# be doing with the "[(0)]" as it shouldn't try to process
        > them. With the [(0)] it doesn't process the "\n\r" and without the
        > [(0)] it works fine. Wierd eh?[/color]

        Well for a start, using "\n\r" is very odd - you should be using
        "\r\n". However, if you don't believe that to be the issue, could you
        post a short but complete program which demonstrates the problem?

        See http://www.pobox.com/~skeet/csharp/complete.html for details of
        what I mean by that.

        --
        Jon Skeet - <skeet@pobox.co m>
        http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
        If replying to the group, please do not mail me too

        Comment

        • Ignacio Machin \( .NET/ C# MVP \)

          #5
          Re: String processing bug in .net 2?

          Hi,

          <greg.merideth@ gmail.com> wrote in message
          news:1138163512 .086648.35070@f 14g2000cwb.goog legroups.com...[color=blue]
          > There's an automated email an application generates, that we've found a
          > wierd processing bug(?) with in .net 2.0
          >
          > The app has the following lines. There are 20 lines above that use
          > "\n\r" that wrap just fine:
          >
          > [20] message.Body += "EONE\n\r";
          > [21] message.Body += "Name [{0}] Reg# [{1}] Owner [{2}]\n\r";
          > [22] message.Body += "Associatio n [{1}] ADOwner [{4}] \n\r";[/color]

          I n addition to the others comments you better use StringBuilder to create
          your message, in the current form you are generating lots of strings for no
          reason



          --
          Ignacio Machin,
          ignacio.machin AT dot.state.fl.us
          Florida Department Of Transportation


          Comment

          • greg.merideth@gmail.com

            #6
            Re: String processing bug in .net 2?

            Since I took over this project I was swapping the design over to
            stringbuilder but I simply haven't gotten to this part yet. I'll cut
            down the code ( from the 300+ message.body += statements) to a 5 line
            example and post it.

            Comment

            Working...