System.Text.Encoding.UTF8 Property

Gets an encoding for the UTF-8 format.


public static Encoding UTF8 { get; }


A System.Text.Encoding for the UTF-8 format.


This property returns a System.Text.UTF8Encoding object that encodes Unicode (UTF-16-encoded) characters into a sequence of one to four bytes per character, and that decodes a UTF-8-encoded byte array to Unicode (UTF-16-encoded) characters. For information about the character encodings supported by the .NET Framework and a discussion of which Unicode encoding to use, see Understanding Encodings.

The System.Text.UTF8Encoding object that is returned by this property may not have the appropriate behavior for your application. It uses replacement fallback to replace each string that it cannot encode and each byte that it cannot decode with a question mark ("?") character. Instead, you can call the UTF8Encoding.#ctor(bool, bool) constructor to instantiate a System.Text.UTF8Encoding object whose fallback is either an System.Text.EncoderFallbackException or a System.Text.DecoderFallbackException, as the following example illustrates.

code reference: System.Text.Encoding.UTF8#1


Namespace: System.Text
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0,,