Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

UTF8Encoding Constructor ()

 

Initializes a new instance of the UTF8Encoding class.

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

public:
UTF8Encoding()

This constructor creates an instance that does not provide a Unicode byte order mark and does not throw an exception when an invalid encoding is detected.

System_CAPS_noteNote

For security reasons, we recommend that you enable error detection by calling a constructor with a throwOnInvalidBytes parameter and setting its value to true.

The following example creates a new UTF8Encoding instance and displays its name.

using namespace System;
using namespace System::Text;
int main()
{
   UTF8Encoding^ utf8 = gcnew UTF8Encoding;
   String^ encodingName = utf8->EncodingName;
   Console::WriteLine( "Encoding name: {0}", encodingName );
}

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:
© 2017 Microsoft