Solved

escape a newline character

Posted on 2006-06-26
7
1,751 Views
Last Modified: 2010-07-27
I'm constructing a statement that the Window's command shell passes on to an application.  As part of that statement, I need to include a newline.  I need that newline not to terminate the statement, but to be passed along to the application.  I know that I can escape some special characters with a backslash.  But, how can I escape a newline?

Here is a simplified example of the issue.  -a, -b, -c are flags that signal the meaning of the following parameter information (embedded in double quotes).

c:\myexe.exe -a "a quoted sequence of information" -b "a quoted sequence that has a double quote embedded in it (\"), escaped with a backslash" -c "a quoted sequence that needs a <NEWLINE> that allows the quoted sequence to continue"

To get a double-quote (parameter -b), I just have to do: \".  What is the equivalent for a newline?

Thanks.
0
Comment
Question by:dannykrouk
7 Comments
 
LVL 10

Expert Comment

by:For-Soft
ID: 16989989
As far as I know, there is no global "special character" you can use.

The program has to support special character formatting, and it will have own special haracter definitions, probably.
0
 
LVL 43

Accepted Solution

by:
Steve Knight earned 125 total points
ID: 16990561
When you say newline is it looking for a line feed (10) carriage return (13) or both?  You might be able to do this using EDIT

Enter Control P then press Control M for ASCII 13 (carriage return) and it inserts a small character.

How the program will handle this I don't know but it does to appear to work in that DOS still sees it as one line.

0
 
LVL 14

Expert Comment

by:cwwkie
ID: 16994944
> -c "a quoted sequence that needs a <NEWLINE> that allows the quoted sequence to continue"

Can't you use something like -c "file:input.txt", and in your exe, read the file input.txt?
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 43

Expert Comment

by:Steve Knight
ID: 17006897
Did it work?  Why the B grade because you ask something that IMHO is not possible though I gave you a way of getting a CR into the commandline, whether it works for your app I don't know of course.
0
 

Author Comment

by:dannykrouk
ID: 17010291
Yes, it did work.  I gave you a "B" because I did not read the Answer Grading guidelines carefully.  You deserve an "A".  I'm contacting a moderator to ask that the grade be upgraded.
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 17013725
Thankyou, appreciated.  

Steve
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Using dates in 'DOS' batch files has always been tricky as it has no built in ways of extracting date information.  There are many tricks using string manipulation to pull out parts of the %date% variable or output of the date /t command but these r…
TOMORROW TOMORROW.BAT is inspired by a question I get asked over and over again; that is, "How can I use batch file commands to obtain tomorrow's date?" The crux of this batch file revolves around the XCOPY command - a technique I discovered w…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

790 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question