Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Powershell: Get default system encoding

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?

like image 508
Ocaso Protal Avatar asked Mar 16 '11 13:03

Ocaso Protal


People also ask

What is the default encoding for PowerShell?

In Windows PowerShell, the default encoding is usually Windows-1252, an extension of latin-1, also known as ISO 8859-1.

What character encoding is PowerShell?

In general, Windows PowerShell uses the Unicode UTF-16LE encoding by default. However, the default encoding used by cmdlets in Windows PowerShell is not consistent. Using any Unicode encoding, except UTF7 , always creates a BOM.

What is the default character encoding in Windows?

The default character encoding is assumed to be UTF-8 on Windows. So if the default operating system Locale is "English_USA. 1252" the default locale for Boost. Locale on Windows would be "en_US.


1 Answers

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)
like image 136
Roman Kuzmin Avatar answered Oct 05 '22 18:10

Roman Kuzmin