Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - How to represent newline as a character constant?

Reply
 
Old 02-13-2008   #1 (permalink)
Christopher Bootland


 
 

How to represent newline as a character constant?

How do I represent a newline character as a character constant suitable for
inclusion in a Char array?

In C, I would use "\n" to represent a character array containing a single
newline character. How would I do this in PowerShell?

TIA
Chris



My System SpecsSystem Spec
Old 02-13-2008   #2 (permalink)
Keith Hill [MVP]


 
 

Re: How to represent newline as a character constant?

"Christopher Bootland" <bootland@xxxxxx> wrote in message
news:13r5213kmtbmm45@xxxxxx
Quote:

> How do I represent a newline character as a character constant suitable
> for inclusion in a Char array?
>
> In C, I would use "\n" to represent a character array containing a single
> newline character. How would I do this in PowerShell?
>
`n

The escape character in PowerShell is a backtick instead of a backslash.
That way you can use backslashes in file paths without having to escape
them. Watch out though. If you used C style single quotes (like you would
for a char in C) that defeats the escape mechansim e.g.:

14> '`n'
`n
15> "`n"


16>

--
Keith

My System SpecsSystem Spec
Old 02-13-2008   #3 (permalink)
Jon


 
 

Re: How to represent newline as a character constant?

"Christopher Bootland" <bootland@xxxxxx> wrote in message
news:13r5213kmtbmm45@xxxxxx
Quote:

> How do I represent a newline character as a character constant suitable
> for inclusion in a Char array?
>
> In C, I would use "\n" to represent a character array containing a single
> newline character. How would I do this in PowerShell?
>
> TIA
> Chris
>


Some more possibilties

[char]13 #Carriage return
[char]10 #Line feed
[[char]13 + [char]10 #Combination of the 2

--
Jon



My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Re: NewLine bug of Windows Speech Recognition revisited Vista General
represent XML in classes/collections (C#) .NET General
Remove Newline from String PowerShell
NewLine in PoSh PowerShell
Problem with [environment]::NewLine and Regular Expression PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46