UTF8Encoding Constructor
Collapse the table of content
Expand the table of content

UTF8Encoding Constructor

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Initializes a new instance of the UTF8Encoding class.

Namespace:  System.Text
Assembly:  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, your applications are recommended to enable error detection by using the constructor that accepts a throwOnInvalidBytes parameter and setting that parameter to true.

The following example demonstrates how to create a new UTF8Encoding instance and display the name of the encoding.


Imports System.Text

Class Example

   Public Shared Sub Demo(ByVal outputBlock As System.Windows.Controls.TextBlock)
      Dim utf8 As New UTF8Encoding()
      Dim encodingName As String = utf8.WebName
      outputBlock.Text &= "Encoding name: " & encodingName & vbCrLf
   End Sub 
End Class 
' The example displays the following output:
'       Encoding name: utf-8


Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2017 Microsoft