473,726 Members | 2,262 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Escape Sequences in Strings

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
Nov 15 '05 #1
3 5723
im not so sure but try to do 'Line1\n\rLine2 '

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

"Ken" <kd******@chart er.net> wrote in message
news:vm******** ****@corp.super news.com...
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

Nov 15 '05 #2

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" <kd******@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: <vm************ @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: ab***@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
|
|
|

Nov 15 '05 #3
Ken
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-*****@online.mi crosoft.com> wrote in message
news:9l******** *****@cpmsftngx a06.phx.gbl...

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" <kd******@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: <vm************ @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: ab***@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
|
|
|

Nov 15 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3371
by: Thomas Philips | last post by:
I have been playing around with reading strings with embedded escape sequences from files both using readline() and codecs.open() and have a question.I create a file "test.txt" with exactly one line: 1\na\n\n2\n\n3 I then open test.txt and then read it using readline(): >>> input_file=file("test.txt") >>> x=input_file.readline() >>> x
6
5019
by: Paul Watson | last post by:
How can I get the escapes from a command line parameter interpreted? The user provides a string on the command line. The string might contain traditional escapes such as \t, \n, etc. It might also contain escaped octal or hex such as \001 or \x09. The escapes are coming into sys.argv without shell interpretation. Do I need to use the compile module to make this work? Any suggestions? ===
6
1681
by: kartik | last post by:
Escape sequences don't seem to work in strings within list comprehensions: >>> print ] What am I missing? Thank you.
8
3454
by: Joe | last post by:
I'm using Python 2.4 on Windows XP SP2. I'm trying to receive a command line argument that is a newline (\n) Here is the command line to use sample.py "\n" Here is a sample.py script
18
7188
by: Steve Litvack | last post by:
Hello, I have built an XMLDocument object instance and I get the following string when I examine the InnerXml property: <?xml version=\"1.0\"?><ROOT><UserData UserID=\"2282\"><Tag1 QID=\"55111\"><Tag2 AID=\"5511101\"></Tag2></Tag1><Tag1 QID=\"55112\"><Tag2 AID=\"5511217\"></Tag2></Tag1><Tag1 QID=\"5512282\"><Tag2 AID=\"551228206\"></Tag2></Tag1><Tag1 QID=\"55114\"><Tag2 AID=\"5511406\"></Tag2></Tag1><Tag1 QID=\"55115\"><Tag2
5
3101
by: nummertolv | last post by:
Hi, My application is receiving strings, representing windows paths, from an external source. When using these paths, by for instance printing them using str() (print path), the backslashes are naturally interpreted as escape characters. >>> print "d:\thedir" d: hedir
4
4277
by: JJ | last post by:
Is there a way of checking that a line with escape sequences in it, has no strings in it (apart from the escape sequences)? i.e. a line with \n\t\t\t\t\t\t\t\r\n would have no string in it a line with \n\t\t\t\thello\t\t\n would hve the string 'hello' in it. In others words, is there a method of removing all escape sequences from a string? I've tried Regex.Unescape(string) but this doesn't not seem to remove the
3
6563
by: slomo | last post by:
How to read strings cantaining escape character from a file and use it as escape sequences? for example, a file 'unicodes.txt' has contents: \u0050\u0079\u0074\u0068\u006f\u006e Now, '\\u0050\\u0079\\u0074\\u0068\\u006f\\u006e\n'
10
2606
by: hanaa | last post by:
Hello there. $str="This is \na ball"; echo $str; Is there a way i can make the text to be as is, without expanding the escape sequences. I know that single quoted strings do not expand escape sequences. But I need to echo text that's been entered by the user in a html textarea as is. And thats why I dont want the escape sequences to be expanded. Thanks, Hanaa
0
8889
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8752
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9257
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9179
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9116
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8099
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6702
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6011
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4784
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.