What happened to special characters

In powershell v3 beta, the backtick still escapes characters but there aren’t any special characters anymore ?:

In V2 you have:
special characters V2
Whereas in V3 you have:
special characters v3

The technet page about special characters in powershell v2 says that:

The following special characters are recognized by Windows PowerShell:

`0 Null
`a Alert
`b Backspace
`f Form feed
`n New line
`r Carriage return
`t Horizontal tab
`v Vertical tab
These characters are case-sensitive.

In V3 we actually need to either use quotes around special characters like this

Write-Host "`n"

or we can use the corresponding ascii table characters:

`0 Null -> [char]0
`a Alert -> [char]7
`b Backspace -> [char]8
`f Form feed -> [char]12
`n New line -> [char]10
`r Carriage return -> [char]13
`t Horizontal tab -> [char]9
`v Vertical tab -> [char]11

and we can now do:

Write-Host ([char]10)            
Write-Host ("test" + [char]9 + "tab")
Advertisements

2 thoughts on “What happened to special characters

  1. Thanks for this. I wasn’t sure how to identify a null char and despite trying the backtick `0, I wasn’t able to remove it. Using the [char]0 worked nicely though.

    • Thx for the feedback 😀
      In PowerShell, you also have a help file about special characters

      Get-Help about_Special_Characters | Out-Host -Paging
      

      This is the one that you can find in PowerShell version 4.0:

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s