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.

Universal Windows Platform
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top
Show: