Hi,
Can anyone point me at the class to convert a string so that it displays
escaped chars as \r, \n etc. please
Its done in the 2005 debugger so I hope its available as a class ??.
Thanks
Graham 13 3010
Graham,
Put an @ in front of the string, example:
string myString = @"\r\n";
Steve
Steve,
Thanks for the vary quick reply :-).
This is the wrong way round however - I already have my string with embedded
control characters - and simply want to display this - with control chars
'shown as escaped (eg \r\n etc.).
Thanks
G.
"steve813" <st******@gmail .com> wrote in message
news:11******** **************@ g49g2000cwa.goo glegroups.com.. . Graham,
Put an @ in front of the string, example:
string myString = @"\r\n";
Steve cs*********@gma il.com wrote: Come to my forum to get help: http://ww
Why would anyone do that when this forum has many experts that really
know their stuff and offer their help willingly day in and day out. Go
fishing elsewhere.
--
Tom Porterfield
Oxns wrote: Steve,
Thanks for the vary quick reply :-).
This is the wrong way round however - I already have my string with embedded control characters - and simply want to display this - with control chars 'shown as escaped (eg \r\n etc.).
string s1 = "\r\n";
string s2 = System.Text.Reg ularExpressions .Regex.Escape(s 1);
--
Tom Porterfield
Are you simply saying that you want to convert the control characters to
"text" that represents the characters.
If so, you might do something like myString.Replac e("\r\n", @"\r\n");
"Oxns" <ox**@community .nospam> wrote in message
news:eU******** ******@TK2MSFTN GP10.phx.gbl... Steve,
Thanks for the vary quick reply :-).
This is the wrong way round however - I already have my string with embedded control characters - and simply want to display this - with control chars 'shown as escaped (eg \r\n etc.).
Thanks
G.
"steve813" <st******@gmail .com> wrote in message news:11******** **************@ g49g2000cwa.goo glegroups.com.. . Graham,
Put an @ in front of the string, example:
string myString = @"\r\n";
Steve
Oxns <ox**@community .nospam> wrote: Can anyone point me at the class to convert a string so that it displays escaped chars as \r, \n etc. please
Its done in the 2005 debugger so I hope its available as a class ??.
Not that I know of, but it's very easy to do. Just run through a series
of replacements;
string replaced = original.Replac e ("\\", "\\\\")
.Replace ("\r", "\\r")
.Replace ("\n", "\\n")
.Replace ("\'", "\\\'")
.Replace ("\"", "\\\")
(etc)
See http://www.pobox.com/~skeet/csharp/faq/#escapes for the complete
list.
--
Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Effectively yes - but for all escaped characters. I can do this the hard way
but assumed/hoped that there was a framework method somewhere which would do
this for me :-O.
Thanks
G.
"Peter Rilling" <pe***@nospam.r illing.net> wrote in message
news:uf******** ******@TK2MSFTN GP14.phx.gbl... Are you simply saying that you want to convert the control characters to "text" that represents the characters.
If so, you might do something like myString.Replac e("\r\n", @"\r\n");
"Oxns" <ox**@community .nospam> wrote in message news:eU******** ******@TK2MSFTN GP10.phx.gbl... Steve,
Thanks for the vary quick reply :-).
This is the wrong way round however - I already have my string with embedded control characters - and simply want to display this - with control chars 'shown as escaped (eg \r\n etc.).
Thanks
G.
"steve813" <st******@gmail .com> wrote in message news:11******** **************@ g49g2000cwa.goo glegroups.com.. . Graham,
Put an @ in front of the string, example:
string myString = @"\r\n";
Steve
Tom,
Yes - I had a look at this but doesn't it only translate regex chars - and
not all string escaped chars ??.
Looks like I'll just do it the hard way - as ever ;-)).
G.
"Tom Porterfield" <tp******@mvps. org> wrote in message
news:eC******** ******@TK2MSFTN GP14.phx.gbl... Oxns wrote: Steve,
Thanks for the vary quick reply :-).
This is the wrong way round however - I already have my string with embedded control characters - and simply want to display this - with control chars 'shown as escaped (eg \r\n etc.).
string s1 = "\r\n"; string s2 = System.Text.Reg ularExpressions .Regex.Escape(s 1); -- Tom Porterfield This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Brett |
last post by:
I've been trying different methods for replacing escaped strings. None
work. I even have a custom Replace() method but still can't get what I
need. Some of the characters I need to replace are:
\r\n with nothing
\" with only single quote.
myString = myString.Replace(@"\"", @""");
Replace(myString, @"\"", @""");
gives this error:
|
by: Anders Both |
last post by:
If I receive a query string on the server that contains escaped char´s like
this:
text=%20asadfdsf%20%C6%D8%C5%20%E6%F8%E5%20AAA
How can I then get the NameValueCollection where the escaped value´s are not
exchanged (unescaped).
If i do like this Request.QueryString I dont get the content that
you see above, but the server try's to exchange the % stuff into something
|
by: Vance Kessler |
last post by:
We are trying write a new ASP.NET page to work with an existing
stateless ASP application. The ASP application creates a cookie and
of course stores the cookie values as escaped strings (using the
vbscript escape function). I am have a terrible time 'unescaping'
that string with C# under ASP.NET.
I have tried the following:
HttpUtility.UrlDecode
HttpUtility.HtmlDecode (this should not work but I tried it)...
|
by: Jonny |
last post by:
Hi,
I am trying to write a C function which will dequote the string in a
char * variable, and unescape any escaped quotes, so that, for example:
"hello"
would become:
hello
|
by: Chason Hayes |
last post by:
I am trying to convert raw binary data to data with escaped octets in
order to store it in a bytea field on postgresql server. I could do this
easily in c/c++ but I need to do it in python. I am not sure how to read
and evaluate the binary value of a byte in a long string when it is a non
printable ascii value in python. I read some ways to use unpack from the
struct module, but i really couldn't understand where that would help. I
looked...
| |
by: Trev |
last post by:
Hi everyone,
Thanks to all who have helped with various issues in the past. I've
come up with a new one though:
I've run some html through a javascript converter; basically it takes
the html and outputs the
following:
var str='';
str+= // whatever text I want
document.write(str);
|
by: Torsten Bronger |
last post by:
Hallöchen!
I need some help with finding matches in a string that has some
characters which are marked as escaped (in a separate list of
indices). Escaped means that they must not be part of any match.
My current approach is to look for matches in substrings with the
escaped characters as boundaries between the substrings. However,
then ^ and $ in the patterns are treated wrongly. (Although I use
startpos and endpos parameters for...
|
by: Michael Goerz |
last post by:
Hi,
I am writing unicode stings into a special text file that requires to
have non-ascii characters as as octal-escaped UTF-8 codes.
For example, the letter "Ã" (latin capital I with acute, code point 205)
would come out as "\303\215".
I will also have to read back from the file later on and convert the
escaped characters back into a unicode string.
|
by: stefcollect |
last post by:
Hi all,
I am pretty new to PHP and am stuck on - what I think - is a generic
string handling problem.
I need to read and manipulate some HTML files and have a problem in
getting some substrings found even when - it is clear - strings are
there. (see a HTML chunk I need to edit at the end of this email).
In particular, the following functions are "randomly" working for me:
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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,...
| |
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...
|
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...
|
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...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |