This documentation is archived and is not being maintained.

Encoding.Default Property

Gets an encoding for the system's current ANSI code page.

Namespace: System.Text
Assembly: mscorlib (in mscorlib.dll)

public static Encoding Default { get; }
/** @property */
public static Encoding get_Default ()

public static function get Default () : Encoding

Property Value

An encoding for the system's current ANSI code page.

To get the encoding associated with the default ANSI code page in the system's regional settings, use GetEncoding(0) or the Default property. To determine the default code pages used on the system, use the Windows API GetSystemDefaultLangID. To determine the current ANSI code page, use the Windows API GetACP.

Caution noteCaution

Different systems might use different encodings as the default; therefore, data streamed from one system to another might be translated incorrectly. To ensure that the encoded bytes are decoded properly, use a Unicode encoding (that is, UTF8Encoding, UnicodeEncoding, or UTF32Encoding) with a preamble. Another option is to use a higher level protocol to ensure that the same format is used for encoding and decoding.

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0