The powershell cmdlet out-file
has the switch -encoding
witch you can set to default
. This default value will use the encoding of the system's current ANSI code page.
My question is: How can I get the name of this default encoding that out-file
will use with powershell?
Asked
Active
Viewed 2.5k times
23

Ocaso Protal
- 19,362
- 8
- 76
- 83
-
1I am not using default anymore. My experience is that "current ANSI code page" translates to "something that other programs are not really fond of except notepad", which I believe is a multibyte Unicode . – J.N. Mar 16 '11 at 14:03
-
@J.N. I don't want to use default, but I have to. Normally I would use UTF8 or UTF16, but in this case I have some problems with legacy code. – Ocaso Protal Mar 16 '11 at 14:10
-
1@Oscaso : I wish you a better luck next time! There should be best practices forbidding the writing of legacy code from the start. I wonder why nobody did it yet :). – J.N. Mar 16 '11 at 14:18
-
@J.N. Thanks! Let's hope so, by goodness! – Ocaso Protal Mar 16 '11 at 14:41
1 Answers
34
Take a look at [System.Text.Encoding]::Default
, I believe it is used as "default".
E.g. in my case:
[System.Text.Encoding]::Default.EncodingName
gets
Cyrillic (Windows)

Roman Kuzmin
- 40,627
- 11
- 95
- 117
-
-
4You can also use [System.Text.Encoding]::Default to get everthing. – wizmagister May 16 '18 at 17:25