Export (0) Print
Expand All

Encoding.UTF8 Property

Gets an encoding for the UTF-8 format.

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

static member UTF8 : Encoding with get

Property Value

Type: System.Text.Encoding
An encoding for the UTF-8 format.

This property returns a 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 Character Encoding in the .NET Framework.

The UTF8Encoding object that is returned by this property might not have the appropriate behavior for your app.

The following example defines an array that consists of the following characters:

  • LATIN SMALL LETTER Z (U+007A)

  • LATIN SMALL LETTER A (U+0061)

  • COMBINING BREVE (U+0306)

  • LATIN SMALL LETTER AE WITH ACUTE (U+01FD)

  • GREEK SMALL LETTER BETA (U+03B2)

  • A surrogate pair (U+D800 U+DD54) that forms GREEK ACROPHONIC ATTIC ONE THOUSAND STATERS (U+10154).

It displays the UTF-16 code units of each character and determines the number of bytes required by a UTF-8 encoder to encode the character array. It then encodes the characters and displays the resulting UTF-8-encoded bytes.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

XNA Framework

Supported in: 3.0, 2.0, 1.0

Portable Class Library

Supported in: Portable Class Library

Supported in: Windows Phone 8.1

Supported in: Windows Phone Silverlight 8.1

Supported in: Windows Phone Silverlight 8
Show:
© 2015 Microsoft