Escape Sequences in Strings

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

    #1

    Escape Sequences in Strings

    HI:

    I'm reading a string that will be displayed in a MessageBox from a resource
    file. The string in the resource file contains escape sequences so they
    will be broken up into multiple lines. e.g. This is line 1\n\nThis is line
    2. When this string is read using a ResourceManager GetString method the
    string is returned @-quoted, i.e as if I entered the literal @"This is
    line1\n\nThis is line 2", causing the escape sequences not to be processed.
    Is there any way around this. I have not been able to find a work around or
    setting that can be used so the escape sequences will be processed.

    Thanks in advance

    Ken Denault


  • gani

    #2
    Re: Escape Sequences in Strings

    im not so sure but try to do 'Line1\n\rLine2 '

    regards,
    --
    gani
    pls visit: http://thedeveloperscorner.com.ph





    "Ken" <kdenault@chart er.net> wrote in message
    news:vmus8u64r1 ok64@corp.super news.com...[color=blue]
    > HI:
    >
    > I'm reading a string that will be displayed in a MessageBox from a[/color]
    resource[color=blue]
    > file. The string in the resource file contains escape sequences so they
    > will be broken up into multiple lines. e.g. This is line 1\n\nThis is[/color]
    line[color=blue]
    > 2. When this string is read using a ResourceManager GetString method the
    > string is returned @-quoted, i.e as if I entered the literal @"This is
    > line1\n\nThis is line 2", causing the escape sequences not to be[/color]
    processed.[color=blue]
    > Is there any way around this. I have not been able to find a work around[/color]
    or[color=blue]
    > setting that can be used so the escape sequences will be processed.
    >
    > Thanks in advance
    >
    > Ken Denault
    >
    >[/color]


    Comment

    • Jeffrey Tan[MSFT]

      #3
      RE: Escape Sequences in Strings


      Hi Ken,

      Can you show me why you need the \n\n to be parsed?
      If you want to display it such as in messagebox, you can
      just pass this string to the method, it will be parsed.
      MessageBox.Show ("This is line1\n\nThis is line 2"), the string
      will be parsed.

      Btw: \n\n is 2 newline escape character.

      Best regards,
      Jeffrey Tan
      Microsoft Online Partner Support
      Get Secure! - www.microsoft.com/security
      This posting is provided "as is" with no warranties and confers no rights.

      --------------------
      | From: "Ken" <kdenault@chart er.net>
      | Newsgroups: microsoft.publi c.dotnet.langua ges.csharp
      | Subject: Escape Sequences in Strings
      | Date: Mon, 22 Sep 2003 18:01:06 -0400
      | Organization: Posted via Supernews, http://www.supernews.com
      | Message-ID: <vmus8u64r1ok64 @corp.supernews .com>
      | X-Priority: 3
      | X-MSMail-Priority: Normal
      | X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
      | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
      | X-Complaints-To: abuse@supernews .com
      | Lines: 16
      | Path:
      cpmsftngxa06.ph x.gbl!TK2MSFTNG P08.phx.gbl!new sfeed00.sul.t-online.de!t-onlin
      e.de!news-spur1.maxwell.s yr.edu!news.max well.syr.edu!sn-xit-03!sn-xit-01!sn-
      post-01!supernews.co m!corp.supernew s.com!not-for-mail
      | Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.langua ges.csharp:1866 44
      | X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.csharp
      |
      | HI:
      |
      | I'm reading a string that will be displayed in a MessageBox from a
      resource
      | file. The string in the resource file contains escape sequences so they
      | will be broken up into multiple lines. e.g. This is line 1\n\nThis is
      line
      | 2. When this string is read using a ResourceManager GetString method the
      | string is returned @-quoted, i.e as if I entered the literal @"This is
      | line1\n\nThis is line 2", causing the escape sequences not to be
      processed.
      | Is there any way around this. I have not been able to find a work around
      or
      | setting that can be used so the escape sequences will be processed.
      |
      | Thanks in advance
      |
      | Ken Denault
      |
      |
      |

      Comment

      • Ken

        #4
        Re: Escape Sequences in Strings

        You are correct in that if it is passed to MessageBox.Show as a hard coded
        string it will do as I would like. The issue is that I'm putting all my
        messages in a resource file so they can be changed without rebuilding the
        application. So when the resource is read by the ResourceManager it is read
        as a quoted string.

        Thanks

        Ken

        "Jeffrey Tan[MSFT]" <v-jetan@online.mi crosoft.com> wrote in message
        news:9l0xLDYgDH A.688@cpmsftngx a06.phx.gbl...[color=blue]
        >
        > Hi Ken,
        >
        > Can you show me why you need the \n\n to be parsed?
        > If you want to display it such as in messagebox, you can
        > just pass this string to the method, it will be parsed.
        > MessageBox.Show ("This is line1\n\nThis is line 2"), the string
        > will be parsed.
        >
        > Btw: \n\n is 2 newline escape character.
        >
        > Best regards,
        > Jeffrey Tan
        > Microsoft Online Partner Support
        > Get Secure! - www.microsoft.com/security
        > This posting is provided "as is" with no warranties and confers no rights.
        >
        > --------------------
        > | From: "Ken" <kdenault@chart er.net>
        > | Newsgroups: microsoft.publi c.dotnet.langua ges.csharp
        > | Subject: Escape Sequences in Strings
        > | Date: Mon, 22 Sep 2003 18:01:06 -0400
        > | Organization: Posted via Supernews, http://www.supernews.com
        > | Message-ID: <vmus8u64r1ok64 @corp.supernews .com>
        > | X-Priority: 3
        > | X-MSMail-Priority: Normal
        > | X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
        > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
        > | X-Complaints-To: abuse@supernews .com
        > | Lines: 16
        > | Path:
        >[/color]
        cpmsftngxa06.ph x.gbl!TK2MSFTNG P08.phx.gbl!new sfeed00.sul.t-online.de!t-onlin[color=blue]
        >[/color]
        e.de!news-spur1.maxwell.s yr.edu!news.max well.syr.edu!sn-xit-03!sn-xit-01!sn-[color=blue]
        > post-01!supernews.co m!corp.supernew s.com!not-for-mail
        > | Xref: cpmsftngxa06.ph x.gbl[/color]
        microsoft.publi c.dotnet.langua ges.csharp:1866 44[color=blue]
        > | X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.csharp
        > |
        > | HI:
        > |
        > | I'm reading a string that will be displayed in a MessageBox from a
        > resource
        > | file. The string in the resource file contains escape sequences so they
        > | will be broken up into multiple lines. e.g. This is line 1\n\nThis is
        > line
        > | 2. When this string is read using a ResourceManager GetString method[/color]
        the[color=blue]
        > | string is returned @-quoted, i.e as if I entered the literal @"This is
        > | line1\n\nThis is line 2", causing the escape sequences not to be
        > processed.
        > | Is there any way around this. I have not been able to find a work[/color]
        around[color=blue]
        > or
        > | setting that can be used so the escape sequences will be processed.
        > |
        > | Thanks in advance
        > |
        > | Ken Denault
        > |
        > |
        > |
        >[/color]


        Comment

        Working...