Escape special characters in a string?
Messages   Related Types
This message was discovered on ASPFriends.com 'ngfx-compiledynamic' list.


Andy Smith
I'm trying to create a method that will take a String entered by the =
user, and generate a String that has all/any language-specific escape =
characters removed/rendered inoperable.

ferinstance...
User inputs the string:=20
He said, "But what\where will it be".

I want the method to transform that into:
[C#]
He said, \"But what\\where will it be\".
[VB]
He said, ""But what\where will it be"".

____________
Andy Smith
Chief Code Monkey=20

Reply to this message...
 
    
Andy Smith
bmV2ZXJtaW5kLi4uIFRoZSB3YXkgaSdtIGRvaW5nIGl0IG5vdy4uLiBUaGUgQ29kZUdlbmVyYXRv
ciBkb2VzIGl0IGZvciBtZSBhdXRvbWFnaWNhbGx5Lg0KDQoJLS0tLS1PcmlnaW5hbCBNZXNzYWdl
LS0tLS0gDQoJRnJvbTogQW5keSBTbWl0aCANCglTZW50OiBUaHUgNC80LzIwMDIgMTI6MzcgUE0g
DQoJVG86IG5nZngtY29tcGlsZWR5bmFtaWMgDQoJQ2M6IA0KCVN1YmplY3Q6IFtuZ2Z4LWNvbXBp
bGVkeW5hbWljXSBFc2NhcGUgc3BlY2lhbCBjaGFyYWN0ZXJzIGluIGEgc3RyaW5nPw0KCQ0KCQ0K
DQoJSSdtIHRyeWluZyB0byBjcmVhdGUgYSBtZXRob2QgdGhhdCB3aWxsIHRha2UgYSBTdHJpbmcg
ZW50ZXJlZCBieSB0aGUgdXNlciwgYW5kIGdlbmVyYXRlIGEgU3RyaW5nIHRoYXQgaGFzIGFsbC9h
bnkgbGFuZ3VhZ2Utc3BlY2lmaWMgZXNjYXBlIGNoYXJhY3RlcnMgcmVtb3ZlZC9yZW5kZXJlZCBp
bm9wZXJhYmxlLg0KCQ0KCWZlcmluc3RhbmNlLi4uDQoJVXNlciBpbnB1dHMgdGhlIHN0cmluZzoN
CglIZSBzYWlkLCAiQnV0IHdoYXRcd2hlcmUgd2lsbCBpdCBiZSIuDQoJDQoJSSB3YW50IHRoZSBt
ZXRob2QgdG8gdHJhbnNmb3JtIHRoYXQgaW50bzoNCglbQyNdDQoJSGUgc2FpZCwgXCJCdXQgd2hh
dFxcd2hlcmUgd2lsbCBpdCBiZVwiLg0KCVtWQl0NCglIZSBzYWlkLCAiIkJ1dCB3aGF0XHdoZXJl
IHdpbGwgaXQgYmUiIi4NCgkNCgkNCglfX19fX19fX19fX18NCglBbmR5IFNtaXRoDQoJQ2hpZWYg
Q29kZSBNb25rZXkNCgkNCgkNCgl8IFtuZ2Z4LWNvbXBpbGVkeW5hbWljXSBtZW1iZXIgQW5keS5T
bWl0aEBtYWN0ZWMuY29tID0gWU9VUiBJRA0KCXwgaHR0cDovL3d3dy5hc3BmcmllbmRzLmNvbS9h
c3BmcmllbmRzL25nZngtY29tcGlsZWR5bmFtaWMuYXNwID0gSk9JTi9RVUlUDQoJDQoNCg=
Reply to this message...
 
    
Peter Brunone

    Sounds like a Big ol' Block o' Replace Statements® to me. Just make sure
you establish an order of precedence, i.e. escape slashes before anything
else for the C# version :)

    I'm curious as to other answers, but I don't know of any nice, clean way to
get around this other than adding the literal indicator "@" to the beginning
of a string in C#.

-Peter

|-----Original Message-----
|From: Andy Smith [mailto:Click here to reveal e-mail address]
|Sent: Thursday, April 04, 2002 1:37 PM
|To: ngfx-compiledynamic
|Subject: [ngfx-compiledynamic] Escape special characters in a string?
|
|I'm trying to create a method that will take a String entered by
|the user, and generate a String that has all/any language-specific
|escape characters removed/rendered inoperable.
|
|ferinstance...
|User inputs the string:
|He said, "But what\where will it be".
|
|I want the method to transform that into:
|[C#]
|He said, \"But what\\where will it be\".
|[VB]
|He said, ""But what\where will it be"".
|____________
|Andy Smith
|Chief Code Monkey

Reply to this message...
 
 




Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
 
 Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us - Terms of Use - Privacy Policy - www.dotnet247.com