View Single Post
Old 05-27-2008   #5 (permalink)
alexandair


 
 

Re: Files created by Powershell are over 2X bigger than files createdby text editor or cmd.exe.

On May 16, 6:36*pm, tom.lux...@xxxxxx wrote:
Quote:

> That did the trick! *Thank you Karl.
>
> I was starting to go down that path (unicode vs. ascii), but hadn't
> nailed it yet.
>
> Can I make ASCII the default output encoding? *Is this wise?
>
> Something that threw me off is $OutputEncoding. *Why doesn't
> $OutputEncoding show Unicode?
>
> PS C:\> $OutputEncoding
> IsSingleByte * * *: True
> BodyName * * * * *: us-ascii
> EncodingName * * *: US-ASCII
> HeaderName * * * *: us-ascii
> WebName * * * * * : us-ascii
> WindowsCodePage * : 1252
> IsBrowserDisplay *: False
> IsBrowserSave * * : False
> IsMailNewsDisplay : True
> IsMailNewsSave * *: True
> EncoderFallback * : System.Text.EncoderReplacementFallback
> DecoderFallback * : System.Text.DecoderReplacementFallback
> IsReadOnly * * * *: True
> CodePage * * * * *: 20127

There are two major ways to write files in PowerShell — with the Out-
File cmdlet and using the Set-Content cmdlet. Out-File will try to
format the output and text files are written in Unicode by default. We
can change that with -encoding parameter. Set-Content will simply
write the output and use ASCII encoding.

Also, when we pipe output data from PowerShell cmdlets into native
applications, the output encoding from PowerShell cmdlets is
controlled by the $OutputEncoding variable, which is by default set to
ASCII. You could find more details here:
http://blogs.msdn.com/powershell/arc...he-rescue.aspx

-aleksandar
http://powershellers.blogspot.com

My System SpecsSystem Spec