.NETGURU
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...
 
 




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification