Encoding.Default Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets the default encoding for this .NET implementation.
public:
static property System::Text::Encoding ^ Default { System::Text::Encoding ^ get(); };
public static System.Text.Encoding Default { get; }
static member Default : System.Text.Encoding
Public Shared ReadOnly Property Default As Encoding
Property Value
The default encoding for this .NET implementation.
Remarks
The behavior of the Default property varies between different .NET implementations:
In .NET Framework: Returns the encoding that corresponds to the system's active code page. This is the same encoding returned by GetEncoding(Int32) when called with a
codepage
argument of0
.In .NET Core and later versions: Always returns a UTF8Encoding object. This behavior was changed to encourage the use of Unicode encodings for better cross-platform compatibility and data integrity.
For the most consistent results across different platforms and .NET implementations, consider using a specific Unicode encoding such as UTF-8 directly instead of relying on the default encoding. You can obtain UTF-8 encoding by calling Encoding.UTF8 or Encoding.GetEncoding(String) with "utf-8".
For more information about this API, see <see href="/dotnet/fundamentals/runtime-libraries/system-text-encoding-default">Supplemental API remarks for Encoding.Default</see>.