UnicodeEncoding 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 UnicodeEncoding class.
Assembly: mscorlib (in mscorlib.dll)
This constructor creates an instance that uses the little-endian byte order, provides a Unicode byte order mark, and does not throw an exception when an invalid encoding is detected.
Note: |
|---|
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 creates a new UnicodeEncoding instance and displays the name of the encoding.
Imports System.Text Class Example Public Shared Sub Demo(ByVal outputBlock As System.Windows.Controls.TextBlock) Dim uni As New UnicodeEncoding() Dim encodingName As String = uni.WebName outputBlock.Text &= "Encoding name: " & encodingName & vbCrLf End Sub 'Main End Class 'UnicodeEncodingExample ' The example displays the following output: ' Encoding name: utf-16
Note: