ConsoleUtility Class

Provides utility members to work with the console.

public static class ConsoleUtility

Properties

NameDescription
SystemDefaultEncodingGets the encoding that a new console of the system starts with.

SystemDefaultEncoding

Gets the encoding that a new console of the system starts with.

public static Encoding SystemDefaultEncoding { get; }

Property value

Encoding On Windows, the encoding of the OEM code page of the system. On every other operating system, UTF-8 without a byte order mark.

Remarks

A console program that sets no encoding writes its redirected output with the encoding of its console. On Windows, a child process started without a console window gets a console of its own, which starts with this encoding, whatever the encoding of the console of its parent. This encoding therefore decodes the output of such a child.

The Process class decodes redirected output with the encoding of the console of the current process by default, or with the ANSI code page of the system when the current process has no console. Neither is the encoding such a child writes with.

This property needs no call to Encoding.RegisterProvider, and the encoding it returns never writes a byte order mark.