473,796 Members | 2,649 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.fr omCharCode(13)+ String.fromChar Code(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.fromCh arCode(13)+Stri ng.fromCharCode (10)+'or that'

produces a new line during output to a mail body in
location="mailt o:td*****@qolor .nl?subject=Thi s 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 1841
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.fr omCharCode(13)+ String.fromChar Code(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.fromCh arCode(13)+Stri ng.fromCharCode (10)+'or that'

produces a new line during output to a mail body in
location="mailt o:tden...@qolor .nl?subject=Thi s 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***@h hgdsk.com?subje ct=This subject&body="
+ escape(mailBody );
alert(newLocati on);
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.f romCharCode(13) +String.fromCha rCode(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.fromCh arCode(13)+Stri ng.fromCharCode (10)+'or that'

produces a new line during output to a mail body in
location="mailt o:tden...@qolor .nl?subject=Thi s 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***@h hgdsk.com?subje ct=This subject&body="
+ escape(mailBody );
alert(newLocati on);
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***@h hgdsk.com?subje ct=This subject&body="
+ escape(mailBody );
alert(newLocat ion);
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
4130
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 it's being written into the page. Is there a way that I can view what is being placed into the page, instead of, or in addition to the javascript code?
12
3348
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 language="JavaScript" type="text/javascript" src="write.js"></script>
18
4895
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) p.stdin.write("hostname\n") however, it doesn't seem to work. I think the cmd.exe is catching it.
2
22036
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 using the Console.Write command. The question is how can I see the outputs in the client machine ? Is there a specific programm to do it or Can I use the prompt window ?
1
4808
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 single-pane form GUI. I've got some stdout print statements in the code ... but I cannot find where in the world the output text is appearing. For printing I tried both: printf ("Hello world\n"); and Console::Write ("Hello World\n");
46
24275
by: Ian Boyd | last post by:
IIS5, on a Windows 2000 Server machine. Debeg.WriteLine "Hello, world!" How can i view it?
0
3588
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 OleDbParameterCollection" whenI try to write a new record. Delete and Modify work fine its just the add record function causes the error.
24
4458
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 help out a newbie? #include <stdio.h> #include <ctype.h> #include <string.h>
7
8969
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 document.write to send output to the browser. This javascript file contains some html code and another script tag. The execution order in Internet Explorer (6&7) appears to be different than that of browsers such as FireFox. Example:
0
9524
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10217
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10003
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 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...
0
9047
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, 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...
1
7546
isladogs
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...
0
5440
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...
0
5568
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3730
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2924
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.