Namespace:
System.Text
Assembly:
mscorlib (in mscorlib.dll)
Visual Basic (Declaration)
Dim instance As New UTF8Encoding()
public function 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.
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 demonstrates how to create a new UTF8Encoding instance and display the name of the encoding.
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
using System;
using System.Text;
class UTF8EncodingExample {
public static void Main() {
UTF8Encoding utf8 = new UTF8Encoding();
String encodingName = utf8.EncodingName;
Console.WriteLine("Encoding name: " + encodingName);
}
}
using namespace System;
using namespace System::Text;
int main()
{
UTF8Encoding^ utf8 = gcnew UTF8Encoding;
String^ encodingName = utf8->EncodingName;
Console::WriteLine( "Encoding name: {0}", encodingName );
}
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC, Xbox 360, Zune
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
.NET Framework
Supported in: 3.5, 3.0, 2.0, 1.1, 1.0
.NET Compact Framework
Supported in: 3.5, 2.0, 1.0
XNA Framework
Supported in: 3.0, 2.0, 1.0
Reference