473,396 Members | 2,059 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

write NLCR to txt output

I try to construct a string for output in the body of an email. My problem
is to get new line/carriage return characters inserted.

On reading a txt file I can split lines successfully with split(/[\r\n]/)
(thanks to Thomas Lahn and Evertjan) or
split(String.fromCharCode(13)+String.fromCharCode( 10)) (which is the
traditional #13#10 found in txt files).
But I fail in the reverse process. Neither

var s = "this \r\nor that"
nor
var s = "this '+String.fromCharCode(13)+String.fromCharCode(10)+ 'or that'

produces a new line during output to a mail body in
location="mailto:td*****@qolor.nl?subject=This or that&body="+s
(Both work fine in alert(s) )

So: how to force a new line in txt output ?
Thanks
Tom
Feb 27 '08 #1
3 1821
On Feb 27, 8:07 am, "Tom de Neef" <tden...@qolor.nlwrote:
I try to construct a string for output in the body of an email. My problem
is to get new line/carriage return characters inserted.

On reading a txt file I can split lines successfully with split(/[\r\n]/)
(thanks to Thomas Lahn and Evertjan) or
split(String.fromCharCode(13)+String.fromCharCode( 10)) (which is the
traditional #13#10 found in txt files).
But I fail in the reverse process. Neither

var s = "this \r\nor that"
nor
var s = "this '+String.fromCharCode(13)+String.fromCharCode(10)+ 'or that'

produces a new line during output to a mail body in
location="mailto:tden...@qolor.nl?subject=This or that&body="+s
(Both work fine in alert(s) )

So: how to force a new line in txt output ?
Thanks
Tom
It took me few attempts to remember how I used to do that, try this:
<script type="text/javascript">
var mailBody = "blah" + '\r\n' + "blah" + '\r\n' + "blah";
var newLocation = "mailto:gs***@hhgdsk.com?subject=This subject&body="
+ escape(mailBody);
alert(newLocation);
location = newLocation;
</script>
Feb 27 '08 #2
"GArlington" wrote in respons to:
>I try to construct a string for output in the body of an email. My
problem
is to get new line/carriage return characters inserted.

On reading a txt file I can split lines successfully with split(/[\r\n]/)
(thanks to Thomas Lahn and Evertjan) or
split(String.fromCharCode(13)+String.fromCharCode (10)) (which is the
traditional #13#10 found in txt files).
But I fail in the reverse process. Neither

var s = "this \r\nor that"
nor
var s = "this '+String.fromCharCode(13)+String.fromCharCode(10)+ 'or that'

produces a new line during output to a mail body in
location="mailto:tden...@qolor.nl?subject=This or that&body="+s
(Both work fine in alert(s) )

So: how to force a new line in txt output ?
Thanks
Tom

It took me few attempts to remember how I used to do that, try this:
<script type="text/javascript">
var mailBody = "blah" + '\r\n' + "blah" + '\r\n' + "blah";
var newLocation = "mailto:gs***@hhgdsk.com?subject=This subject&body="
+ escape(mailBody);
alert(newLocation);
location = newLocation;
</script>
Ah, escape(), that does it. Thank you.
Tom
Feb 27 '08 #3
Tom de Neef wrote:
"GArlington" wrote in respons to:
>It took me few attempts to remember how I used to do that, try this:
<script type="text/javascript">
var mailBody = "blah" + '\r\n' + "blah" + '\r\n' + "blah";
var newLocation = "mailto:gs***@hhgdsk.com?subject=This subject&body="
+ escape(mailBody);
alert(newLocation);
location = newLocation;
</script>

Ah, escape(), that does it. Thank you.
Nevertheless, it is likely that the `mailto:' URI is going to fail
miserably, given the apparently predominant amount of Web mail accounts,
and the existence of Internet cafés. You are much better off using a
server-side formmailer instead noawadys, also regarding e-mail spam.

BTW, it's called CRLF (Carriage Return, Line Feed: \r [0x0D] followed by \n
[0x0A]).
PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
Feb 28 '08 #4

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

Similar topics

14
by: Eli | last post by:
I've got a script that I'm trying to debug which uses document.write() to place HTML within a page. In both IE6 and Firefox when I view source, I see only the script itself and not any HTML as...
12
by: Radek Maciaszek | last post by:
Hi It's very interesting problem. I couldn't even find any inforamtion about it on the google. I think that the best way of explain will be this simple example: <html> <body> <script...
18
by: jas | last post by:
Hi, I would like to start a new process and be able to read/write from/to it. I have tried things like... import subprocess as sp p = sp.Popen("cmd.exe", stdout=sp.PIPE)...
2
by: Boba | last post by:
Hi, I'm programming a WinForm application. I would like to enter commands that will send output that will help me to locate bugs in the future. I know that there is a way to send output by...
1
by: noleander | last post by:
Hi. I've got a C++ program written in Visual C++ 2003. The program is trivial, created with the Program-creation wizard: used the .NET "Form" template. The program has a trivial...
46
by: Ian Boyd | last post by:
IIS5, on a Windows 2000 Server machine. Debeg.WriteLine "Hello, world!" How can i view it?
0
by: DC | last post by:
The problem I'm using the .NET GridView and FormView objects for the first time and im getting the error "An OleDbParameter with ParameterName '@ID' is not contained by this...
24
by: Bill | last post by:
Hello, I'm trying to output buffer content to a file. I either get an access violation error, or crazy looking output in the file depending on which method I use to write the file. Can anyone...
7
by: sj071 | last post by:
I'm little more than a novice when it comes to javascript, and this particular problem has been driving me mad for the past few days... The Problem: I have a javascript file that uses...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
Oralloy
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,...
0
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...
0
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...
0
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,...

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.