UTF32Encoding 생성자
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
UTF32Encoding 클래스의 새 인스턴스를 초기화합니다.
오버로드
| Name | Description |
|---|---|
| UTF32Encoding() |
UTF32Encoding 클래스의 새 인스턴스를 초기화합니다. |
| UTF32Encoding(Boolean, Boolean) |
UTF32Encoding 클래스의 새 인스턴스를 초기화합니다. 매개 변수는 big endian 바이트 순서를 사용할지 여부와 메서드가 GetPreamble() 유니코드 바이트 순서 표시를 반환하는지 여부를 지정합니다. |
| UTF32Encoding(Boolean, Boolean, Boolean) |
UTF32Encoding 클래스의 새 인스턴스를 초기화합니다. 매개 변수는 big endian 바이트 순서를 사용할지 여부, 유니코드 바이트 순서 표시를 제공할지 여부 및 잘못된 인코딩이 검색될 때 예외를 throw할지 여부를 지정합니다. |
UTF32Encoding()
- Source:
- UTF32Encoding.cs
- Source:
- UTF32Encoding.cs
- Source:
- UTF32Encoding.cs
- Source:
- UTF32Encoding.cs
- Source:
- UTF32Encoding.cs
UTF32Encoding 클래스의 새 인스턴스를 초기화합니다.
public:
UTF32Encoding();
public UTF32Encoding();
Public Sub New ()
예제
다음 예제에서는 다른 UTF32Encoding 인스턴스에 대한 바이트 순서 표시를 검색하고 표시합니다.
using System;
using System.Text;
public class SamplesUTF32Encoding
{
public static void Main()
{
// Create instances of UTF32Encoding, with the byte order mark and without.
UTF32Encoding u32LeNone = new UTF32Encoding();
UTF32Encoding u32BeNone = new UTF32Encoding( true, false );
UTF32Encoding u32LeBom = new UTF32Encoding( false, true );
UTF32Encoding u32BeBom = new UTF32Encoding( true, true );
// Display the preamble for each instance.
PrintHexBytes( u32LeNone.GetPreamble() );
PrintHexBytes( u32BeNone.GetPreamble() );
PrintHexBytes( u32LeBom.GetPreamble() );
PrintHexBytes( u32BeBom.GetPreamble() );
}
public static void PrintHexBytes( byte[] bytes )
{
if (( bytes == null ) || ( bytes.Length == 0 ))
{
Console.WriteLine( "<none>" );
}
else {
for ( int i = 0; i < bytes.Length; i++ )
Console.Write( "{0:X2} ", bytes[i] );
Console.WriteLine();
}
}
}
/*
This example displays the following output.
FF FE 00 00
<none>
FF FE 00 00
00 00 FE FF
*/
Imports System.Text
Public Class SamplesUTF32Encoding
Public Shared Sub Main()
' Create instances of UTF32Encoding, with the byte order mark and without.
Dim u32LeNone As New UTF32Encoding()
Dim u32BeNone As New UTF32Encoding(True, False)
Dim u32LeBom As New UTF32Encoding(False, True)
Dim u32BeBom As New UTF32Encoding(True, True)
' Display the preamble for each instance.
PrintHexBytes(u32LeNone.GetPreamble())
PrintHexBytes(u32BeNone.GetPreamble())
PrintHexBytes(u32LeBom.GetPreamble())
PrintHexBytes(u32BeBom.GetPreamble())
End Sub
Public Shared Sub PrintHexBytes(bytes() As Byte)
If bytes Is Nothing OrElse bytes.Length = 0 Then
Console.WriteLine("<none>")
Else
Dim i As Integer
For i = 0 To bytes.Length - 1
Console.Write("{0:X2} ", bytes(i))
Next i
Console.WriteLine()
End If
End Sub
End Class
'This example displays the following output:
' FF FE 00 00
' FF FE 00 00
' 00 00 FE FF
설명
이 생성자는 작은 엔디안 바이트 순서를 사용하는 인스턴스를 만들고 유니코드 바이트 순서 표시를 제공하며 잘못된 인코딩이 검색될 때 예외를 throw하지 않습니다.
Caution
보안상의 이유로 생성자를 호출하고 해당 인수를
적용 대상
UTF32Encoding(Boolean, Boolean)
- Source:
- UTF32Encoding.cs
- Source:
- UTF32Encoding.cs
- Source:
- UTF32Encoding.cs
- Source:
- UTF32Encoding.cs
- Source:
- UTF32Encoding.cs
UTF32Encoding 클래스의 새 인스턴스를 초기화합니다. 매개 변수는 big endian 바이트 순서를 사용할지 여부와 메서드가 GetPreamble() 유니코드 바이트 순서 표시를 반환하는지 여부를 지정합니다.
public:
UTF32Encoding(bool bigEndian, bool byteOrderMark);
public UTF32Encoding(bool bigEndian, bool byteOrderMark);
new System.Text.UTF32Encoding : bool * bool -> System.Text.UTF32Encoding
Public Sub New (bigEndian As Boolean, byteOrderMark As Boolean)
매개 변수
- bigEndian
- Boolean
true big endian 바이트 순서(가장 중요한 바이트 먼저)를 사용하거나 false 작은 엔디안 바이트 순서(가장 중요하지 않은 바이트 우선)를 사용하려면
- byteOrderMark
- Boolean
true유니코드 바이트 순서 표시가 제공되도록 지정하려면 그렇지 않으면 . false
예제
다음 예제에서는 다른 UTF32Encoding 인스턴스에 대한 바이트 순서 표시를 검색하고 표시합니다.
using System;
using System.Text;
public class SamplesUTF32Encoding
{
public static void Main()
{
// Create instances of UTF32Encoding, with the byte order mark and without.
UTF32Encoding u32LeNone = new UTF32Encoding();
UTF32Encoding u32BeNone = new UTF32Encoding( true, false );
UTF32Encoding u32LeBom = new UTF32Encoding( false, true );
UTF32Encoding u32BeBom = new UTF32Encoding( true, true );
// Display the preamble for each instance.
PrintHexBytes( u32LeNone.GetPreamble() );
PrintHexBytes( u32BeNone.GetPreamble() );
PrintHexBytes( u32LeBom.GetPreamble() );
PrintHexBytes( u32BeBom.GetPreamble() );
}
public static void PrintHexBytes( byte[] bytes )
{
if (( bytes == null ) || ( bytes.Length == 0 ))
{
Console.WriteLine( "<none>" );
}
else {
for ( int i = 0; i < bytes.Length; i++ )
Console.Write( "{0:X2} ", bytes[i] );
Console.WriteLine();
}
}
}
/*
This example displays the following output.
FF FE 00 00
<none>
FF FE 00 00
00 00 FE FF
*/
Imports System.Text
Public Class SamplesUTF32Encoding
Public Shared Sub Main()
' Create instances of UTF32Encoding, with the byte order mark and without.
Dim u32LeNone As New UTF32Encoding()
Dim u32BeNone As New UTF32Encoding(True, False)
Dim u32LeBom As New UTF32Encoding(False, True)
Dim u32BeBom As New UTF32Encoding(True, True)
' Display the preamble for each instance.
PrintHexBytes(u32LeNone.GetPreamble())
PrintHexBytes(u32BeNone.GetPreamble())
PrintHexBytes(u32LeBom.GetPreamble())
PrintHexBytes(u32BeBom.GetPreamble())
End Sub
Public Shared Sub PrintHexBytes(bytes() As Byte)
If bytes Is Nothing OrElse bytes.Length = 0 Then
Console.WriteLine("<none>")
Else
Dim i As Integer
For i = 0 To bytes.Length - 1
Console.Write("{0:X2} ", bytes(i))
Next i
Console.WriteLine()
End If
End Sub
End Class
'This example displays the following output:
' FF FE 00 00
' FF FE 00 00
' 00 00 FE FF
설명
이 생성자는 잘못된 인코딩이 검색될 때 예외를 throw하지 않는 인스턴스를 만듭니다.
Caution
보안상의 이유로 생성자를 호출하고 해당 인수를
추가 정보
적용 대상
UTF32Encoding(Boolean, Boolean, Boolean)
- Source:
- UTF32Encoding.cs
- Source:
- UTF32Encoding.cs
- Source:
- UTF32Encoding.cs
- Source:
- UTF32Encoding.cs
- Source:
- UTF32Encoding.cs
UTF32Encoding 클래스의 새 인스턴스를 초기화합니다. 매개 변수는 big endian 바이트 순서를 사용할지 여부, 유니코드 바이트 순서 표시를 제공할지 여부 및 잘못된 인코딩이 검색될 때 예외를 throw할지 여부를 지정합니다.
public:
UTF32Encoding(bool bigEndian, bool byteOrderMark, bool throwOnInvalidCharacters);
public UTF32Encoding(bool bigEndian, bool byteOrderMark, bool throwOnInvalidCharacters);
new System.Text.UTF32Encoding : bool * bool * bool -> System.Text.UTF32Encoding
Public Sub New (bigEndian As Boolean, byteOrderMark As Boolean, throwOnInvalidCharacters As Boolean)
매개 변수
- bigEndian
- Boolean
true big endian 바이트 순서(가장 중요한 바이트 먼저)를 사용하거나 false 작은 엔디안 바이트 순서(가장 중요하지 않은 바이트 우선)를 사용하려면
- byteOrderMark
- Boolean
true유니코드 바이트 순서 표시가 제공되도록 지정하려면 그렇지 않으면 . false
- throwOnInvalidCharacters
- Boolean
true잘못된 인코딩이 검색될 때 예외가 throw되도록 지정하려면 다음을 실행합니다. 그렇지 않으면 . false
예제
다음 예제에서는 오류 검색을 사용하도록 설정하고 사용하지 않는 동작 UTF32Encoding을 보여 줍니다.
using System;
using System.Text;
public class Example
{
public static void Main()
{
// Create a UTF32Encoding object with error detection enabled.
var encExc = new UTF32Encoding(! BitConverter.IsLittleEndian, true, true);
// Create a UTF32Encoding object with error detection disabled.
var encRepl = new UTF32Encoding(! BitConverter.IsLittleEndian, true, false);
// Create a byte arrays from a string, and add an invalid surrogate pair, as follows.
// Latin Small Letter Z (U+007A)
// Latin Small Letter A (U+0061)
// Combining Breve (U+0306)
// Latin Small Letter AE With Acute (U+01FD)
// Greek Small Letter Beta (U+03B2)
// a high-surrogate value (U+D8FF)
// an invalid low surrogate (U+01FF)
String s = "za\u0306\u01FD\u03B2";
// Encode the string using little-endian byte order.
int index = encExc.GetByteCount(s);
Byte[] bytes = new Byte[index + 4];
encExc.GetBytes(s, 0, s.Length, bytes, 0);
bytes[index] = 0xFF;
bytes[index + 1] = 0xD8;
bytes[index + 2] = 0xFF;
bytes[index + 3] = 0x01;
// Decode the byte array with error detection.
Console.WriteLine("Decoding with error detection:");
PrintDecodedString(bytes, encExc);
// Decode the byte array without error detection.
Console.WriteLine("Decoding without error detection:");
PrintDecodedString(bytes, encRepl);
}
// Decode the bytes and display the string.
public static void PrintDecodedString(Byte[] bytes, Encoding enc)
{
try {
Console.WriteLine(" Decoded string: {0}", enc.GetString(bytes, 0, bytes.Length));
}
catch (DecoderFallbackException e) {
Console.WriteLine(e.ToString());
}
Console.WriteLine();
}
}
// The example displays the following output:
// Decoding with error detection:
// System.Text.DecoderFallbackException: Unable to translate bytes [FF][D8][FF][01] at index
// 20 from specified code page to Unicode.
// at System.Text.DecoderExceptionFallbackBuffer.Throw(Byte[] bytesUnknown, Int32 index)
// at System.Text.DecoderExceptionFallbackBuffer.Fallback(Byte[] bytesUnknown, Int32 index
// )
// at System.Text.DecoderFallbackBuffer.InternalFallback(Byte[] bytes, Byte* pBytes)
// at System.Text.UTF32Encoding.GetCharCount(Byte* bytes, Int32 count, DecoderNLS baseDeco
// der)
// at System.Text.UTF32Encoding.GetString(Byte[] bytes, Int32 index, Int32 count)
// at Example.PrintDecodedString(Byte[] bytes, Encoding enc)
//
// Decoding without error detection:
// Decoded string: zăǽβ�
Imports System.Text
Public Module Example
Public Sub Main()
' Create a UTF32Encoding object with error detection enabled.
Dim encExc As New UTF32Encoding(Not BitConverter.IsLittleEndian, True, True)
' Create a UTF32Encoding object with error detection disabled.
Dim encRepl As New UTF32Encoding(Not BitConverter.IsLittleEndian, True, False)
' Create a byte arrays from a string, and add an invalid surrogate pair, as follows.
' Latin Small Letter Z (U+007A)
' Latin Small Letter A (U+0061)
' Combining Breve (U+0306)
' Latin Small Letter AE With Acute (U+01FD)
' Greek Small Letter Beta (U+03B2)
' a high-surrogate value (U+D8FF)
' an invalid low surrogate (U+01FF)
Dim s As String = "za" & ChrW(&H0306) & ChrW(&H01FD) & ChrW(&H03B2)
' Encode the string using little-endian byte order.
Dim index As Integer = encExc.GetBytecount(s)
Dim bytes(index + 3) As Byte
encExc.GetBytes(s, 0, s.Length, bytes, 0)
bytes(index) = &hFF
bytes(index + 1) = &hD8
bytes(index + 2) = &hFF
bytes(index + 3) = &h01
' Decode the byte array with error detection.
Console.WriteLine("Decoding with error detection:")
PrintDecodedString(bytes, encExc)
' Decode the byte array without error detection.
Console.WriteLine("Decoding without error detection:")
PrintDecodedString(bytes, encRepl)
End Sub
' Decode the bytes and display the string.
Public Sub PrintDecodedString(bytes() As Byte, enc As Encoding)
Try
Console.WriteLine(" Decoded string: {0}", enc.GetString(bytes, 0, bytes.Length))
Catch e As DecoderFallbackException
Console.WriteLine(e.ToString())
End Try
Console.WriteLine()
End Sub
End Module
' The example displays the following output:
' Decoding with error detection:
' System.Text.DecoderFallbackException: Unable to translate bytes [FF][D8][FF][01] at index
' 20 from specified code page to Unicode.
' at System.Text.DecoderExceptionFallbackBuffer.Throw(Byte[] bytesUnknown, Int32 index)
' at System.Text.DecoderExceptionFallbackBuffer.Fallback(Byte[] bytesUnknown, Int32 index
' )
' at System.Text.DecoderFallbackBuffer.InternalFallback(Byte[] bytes, Byte* pBytes)
' at System.Text.UTF32Encoding.GetCharCount(Byte* bytes, Int32 count, DecoderNLS baseDeco
' der)
' at System.Text.UTF32Encoding.GetString(Byte[] bytes, Int32 index, Int32 count)
' at Example.PrintDecodedString(Byte[] bytes, Encoding enc)
'
' Decoding without error detection:
' Decoded string: zăǽβ�
설명
이 throwOnInvalidCharacters경우 true 잘못된 바이트 시퀀스를 검색하는 메서드가 throw됩니다System.ArgumentException. 그렇지 않으면 메서드가 예외를 throw하지 않고 잘못된 시퀀스가 무시됩니다.
Caution
보안상의 이유로 생성자를 호출하고 해당 인수를