Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 7th, 2006, 12:50 AM
Authorized User
 
Join Date: Dec 2005
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to kapi.goel
Default escape squences in C#

Experts,

I am not able to use escape sequences in C#.

Example i am trying to say :-

string str = "hi i am in \"double quotes\". \n new line \t tabing";
Response.Write(str);

so result i am getting is:-
hi i am in "double quotes". new line tabing

so \n and \t sequence is not working, but \" is working fine.

Don't know what is the reason ?



KG
__________________
KG
 
Old January 7th, 2006, 05:09 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Looking at the Response.Write, it appears you're using this in a web app.

I think that \n and \t ARE applied, but it's not visible on screen. If you look at the resulting HTML source in the browser,you'll see the source is formatted as expected. To have these characters appear on screen as well, use <br /> instead of \n.
\t (tab) can be solved in a different way; one is using multiple successive " " sequences.

HtH,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old January 8th, 2006, 10:51 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Even multiple " " may not be sufficient. You may need several "&nbsp;". The browser usually ignores many " " in sequence and reduces them to a single " ".

-Peter
 
Old January 8th, 2006, 10:59 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

I think I had that, but the &nbsp; was changed by the forum....

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.

 
Old January 9th, 2006, 03:31 AM
Authorized User
 
Join Date: Dec 2005
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to kapi.goel
Default

Quote:
quote:Originally posted by Imar
 Looking at the Response.Write, it appears you're using this in a web app.

I think that \n and \t ARE applied, but it's not visible on screen. If you look at the resulting HTML source in the browser,you'll see the source is formatted as expected. To have these characters appear on screen as well, use <br /> instead of \n.
\t (tab) can be solved in a different way; one is using multiple successive " " sequences.

HtH,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.

Imar, I used <br> its working fine with IE.

But actually i am creating oen link, on click of that link opening outlook with all the email details. like cc, bcc, subject and body.

Problem is outlook is taking <br> as part of the string not as a new line. So i want to have a formatted email in the Outlook send page.

How can i do that ??

Tnx,


KG
 
Old January 9th, 2006, 01:22 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Does Outlook understand the \r\n construct?

The <br /> is used in the browser but apparently Outlook has trouble understanding that. If \r\n doesn't work, I am not sure that what you want is possible...

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old January 10th, 2006, 12:21 AM
Authorized User
 
Join Date: Dec 2005
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to kapi.goel
Default

\r\n is not working....

KG
 
Old January 10th, 2006, 10:24 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

Take a look at this ancient post I made in the past at p2p.wrox.com

It's over 5 years old, so it probably won't work anymore with more intelligent privacy aware mail applications like Outlook, but it's worth a try...

http://p2p.wrox.com/archive/html_cod.../2000-12/6.asp

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Don't escape the whole thing with CDATA. akentanaka XSLT 2 December 4th, 2008 09:22 PM
Escape ' lafilip XSLT 3 May 22nd, 2007 03:31 AM
Forgotten escape character chrscote Classic ASP Basics 4 December 4th, 2006 09:37 AM
Escape char for '-' mattastic Access 1 October 6th, 2005 03:27 PM
Need Escape Character? shaileshmark SQL Server 2000 5 July 20th, 2004 12:35 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.