Export (0) Print
Expand All

UTF8Encoding Constructor

Initializes a new instance of the UTF8Encoding class.

Namespace:  System.Text
Assemblies:   System.Text.Encoding.Extensions (in System.Text.Encoding.Extensions.dll)
  mscorlib (in mscorlib.dll)

'Declaration
Public Sub New

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.

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.

Imports System
Imports System.Text

Class UTF8EncodingExample

    Public Shared Sub Main()
        Dim utf8 As New UTF8Encoding()
        Dim encodingName As String = utf8.EncodingName
        Console.WriteLine("Encoding name: " & encodingName)
    End Sub 'Main
End Class 'UTF8EncodingExample

.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