Escape Sequences in Strings

  • Thread starter Thread starter Ken
  • Start date Start date
K

Ken

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
 
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" <[email protected]>
| Newsgroups: microsoft.public.dotnet.languages.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: <[email protected]>
| 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: (e-mail address removed)
| Lines: 16
| Path:
cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed00.sul.t-online.de!t-onlin
e.de!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!sn-xit-03!sn-xit-01!sn-
post-01!supernews.com!corp.supernews.com!not-for-mail
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:186644
| X-Tomcat-NG: microsoft.public.dotnet.languages.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
|
|
|
 
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
 
Back
Top