Encoding.Default Property

Gets an encoding for the operating 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

Not applicable.

Property Value

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

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

Caution noteCaution:

Different operating systems might use different encodings as the default. Therefore, data streamed from one operating system to another might be translated incorrectly. To ensure that the encoded bytes are decoded properly, your application should 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.

The system ANSI code page defined by Default covers the ASCII set of characters, but the encoding is different from the encoding for ASCII. Since all Default encodings lose data, your application might use UTF8 or Encoding instead. UTF-8 is often identical in the U+00 to U+7F range, but can encode other characters without loss.

Windows 98, Windows Server 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 Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

XNA Framework

Supported in: 1.0

Community Additions