UTF32Encoding 클래스

정의

유니코드 문자의 UTF-32 인코딩을 나타냅니다.

public ref class UTF32Encoding sealed : System::Text::Encoding
public sealed class UTF32Encoding : System.Text.Encoding
[System.Serializable]
public sealed class UTF32Encoding : System.Text.Encoding
type UTF32Encoding = class
    inherit Encoding
[<System.Serializable>]
type UTF32Encoding = class
    inherit Encoding
Public NotInheritable Class UTF32Encoding
Inherits Encoding
상속
UTF32Encoding
특성

예제

다음 예제에서는 오류 검색을 사용 하 고 사용 하지 않고 개체의 UTF32Encoding 동작을 보여 줍니다. 마지막 4바이트가 잘못된 서로게이트 쌍을 나타내는 바이트 배열을 만듭니다. 상위 서로게이트 U+D8FF 뒤에 U+01FF가 잇습니다. U+01FF는 낮은 서로게이트 범위를 벗어났습니다(0xDFFF 통해 0xDC00). 오류 검색 없이 UTF32 디코더는 대체 대체를 사용하여 잘못된 서로게이트 쌍을 REPLACEMENT CHARACTER(U+FFFD)로 바꿉니다.

using namespace System;
using namespace System::Text;
void PrintDecodedString( array<Byte>^bytes, Encoding^ enc );
int main()
{
   
   // Create an instance of UTF32Encoding using little-endian byte order.
   // This will be used for encoding.
   UTF32Encoding^ u32LE = gcnew UTF32Encoding( false,true );
   
   // Create two instances of UTF32Encoding using big-endian byte order: one with error detection and one without.
   // These will be used for decoding.
   UTF32Encoding^ u32withED = gcnew UTF32Encoding( true,true,true );
   UTF32Encoding^ u32noED = gcnew UTF32Encoding( true,true,false );
   
   // Create byte arrays from the same string containing the following characters:
   //    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)
   String^ myStr = L"za\u0306\u01FD\u03B2\xD8FF\xDCFF";
   
   // Encode the string using little-endian byte order.
   array<Byte>^myBytes = gcnew array<Byte>(u32LE->GetByteCount( myStr ));
   u32LE->GetBytes( myStr, 0, myStr->Length, myBytes, 0 );
   
   // Decode the byte array with error detection.
   Console::WriteLine( "Decoding with error detection:" );
   PrintDecodedString( myBytes, u32withED );
   
   // Decode the byte array without error detection.
   Console::WriteLine( "Decoding without error detection:" );
   PrintDecodedString( myBytes, u32noED );
}


// Decode the bytes and display the string.
void PrintDecodedString( array<Byte>^bytes, Encoding^ enc )
{
   try
   {
      Console::WriteLine( "   Decoded string: {0}", enc->GetString( bytes, 0, bytes->Length ) );
   }
   catch ( System::ArgumentException^ e ) 
   {
      Console::WriteLine( e );
   }

   Console::WriteLine();
}
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ăǽβ�

다음 예제에서는 개체를 사용하여 유니코드 문자 문자열을 바이트 배열로 UTF32Encoding 인코딩합니다. 그런 다음 바이트 배열을 문자열로 디코딩하여 데이터 손실이 없음을 보여 줍니다.

using System;
using System.Text;

public class Example
{
    public static void Main()
    {
        // The encoding.
        var enc = new UTF32Encoding();
        
        // Create a string.
        String s = "This string contains two characters " +
                   "with codes outside the ASCII code range: " +
                   "Pi (\u03A0) and Sigma (\u03A3).";
        Console.WriteLine("Original string:");
        Console.WriteLine("   {0}", s);
        
        // Encode the string.
        Byte[] encodedBytes = enc.GetBytes(s);
        Console.WriteLine();
        Console.WriteLine("Encoded bytes:");
        for (int ctr = 0; ctr < encodedBytes.Length; ctr++) {
            Console.Write("[{0:X2}]{1}", encodedBytes[ctr],
                                         (ctr + 1) % 4 == 0 ? " " : "" );
            if ((ctr + 1) % 16 == 0) Console.WriteLine();
        }
        Console.WriteLine();
        
        // Decode bytes back to string.
        // Notice Pi and Sigma characters are still present.
        String decodedString = enc.GetString(encodedBytes);
        Console.WriteLine();
        Console.WriteLine("Decoded string:");
        Console.WriteLine("   {0}", decodedString);
    }
}
// The example displays the following output:
//    Original string:
//       This string contains two characters with codes outside the ASCII code range:
//    Pi (π) and Sigma (Σ).
//
//    Encoded bytes:
//    [54][00][00][00] [68][00][00][00] [69][00][00][00] [73][00][00][00]
//    [20][00][00][00] [73][00][00][00] [74][00][00][00] [72][00][00][00]
//    [69][00][00][00] [6E][00][00][00] [67][00][00][00] [20][00][00][00]
//    [63][00][00][00] [6F][00][00][00] [6E][00][00][00] [74][00][00][00]
//    [61][00][00][00] [69][00][00][00] [6E][00][00][00] [73][00][00][00]
//    [20][00][00][00] [74][00][00][00] [77][00][00][00] [6F][00][00][00]
//    [20][00][00][00] [63][00][00][00] [68][00][00][00] [61][00][00][00]
//    [72][00][00][00] [61][00][00][00] [63][00][00][00] [74][00][00][00]
//    [65][00][00][00] [72][00][00][00] [73][00][00][00] [20][00][00][00]
//    [77][00][00][00] [69][00][00][00] [74][00][00][00] [68][00][00][00]
//    [20][00][00][00] [63][00][00][00] [6F][00][00][00] [64][00][00][00]
//    [65][00][00][00] [73][00][00][00] [20][00][00][00] [6F][00][00][00]
//    [75][00][00][00] [74][00][00][00] [73][00][00][00] [69][00][00][00]
//    [64][00][00][00] [65][00][00][00] [20][00][00][00] [74][00][00][00]
//    [68][00][00][00] [65][00][00][00] [20][00][00][00] [41][00][00][00]
//    [53][00][00][00] [43][00][00][00] [49][00][00][00] [49][00][00][00]
//    [20][00][00][00] [63][00][00][00] [6F][00][00][00] [64][00][00][00]
//    [65][00][00][00] [20][00][00][00] [72][00][00][00] [61][00][00][00]
//    [6E][00][00][00] [67][00][00][00] [65][00][00][00] [3A][00][00][00]
//    [20][00][00][00] [50][00][00][00] [69][00][00][00] [20][00][00][00]
//    [28][00][00][00] [A0][03][00][00] [29][00][00][00] [20][00][00][00]
//    [61][00][00][00] [6E][00][00][00] [64][00][00][00] [20][00][00][00]
//    [53][00][00][00] [69][00][00][00] [67][00][00][00] [6D][00][00][00]
//    [61][00][00][00] [20][00][00][00] [28][00][00][00] [A3][03][00][00]
//    [29][00][00][00] [2E][00][00][00]
//
//    Decoded string:
//       This string contains two characters with codes outside the ASCII code range:
//    Pi (π) and Sigma (Σ).
Imports System.Text

Class Example
    Public Shared Sub Main()
        ' The encoding.
        Dim enc As New UTF32Encoding()
        
        ' Create a string.
        Dim s As String =
            "This string contains two characters " &
            "with codes outside the ASCII code range: " &
            "Pi (" & ChrW(&h03A0) & ") and Sigma (" & ChrW(&h03A3) & ")."
        Console.WriteLine("Original string:")
        Console.WriteLine("   {0}", s)
        
        ' Encode the string.
        Dim encodedBytes As Byte() = enc.GetBytes(s)
        Console.WriteLine()
        Console.WriteLine("Encoded bytes:")
        For ctr As Integer = 0 To encodedBytes.Length - 1
            Console.Write("[{0:X2}]{1}", encodedBytes(ctr),
                                         If((ctr + 1) Mod 4 = 0, " ", "" ))
            If (ctr + 1) Mod 16 = 0 Then Console.WriteLine()
        Next
        Console.WriteLine()
        
        ' Decode bytes back to string.
        ' Notice Pi and Sigma characters are still present.
        Dim decodedString As String = enc.GetString(encodedBytes)
        Console.WriteLine()
        Console.WriteLine("Decoded string:")
        Console.WriteLine("   {0}", decodedString)
    End Sub
End Class
' The example displays the following output:
'    Original string:
'       This string contains two characters with codes outside the ASCII code range:
'    Pi (π) and Sigma (Σ).
'
'    Encoded bytes:
'    [54][00][00][00] [68][00][00][00] [69][00][00][00] [73][00][00][00]
'    [20][00][00][00] [73][00][00][00] [74][00][00][00] [72][00][00][00]
'    [69][00][00][00] [6E][00][00][00] [67][00][00][00] [20][00][00][00]
'    [63][00][00][00] [6F][00][00][00] [6E][00][00][00] [74][00][00][00]
'    [61][00][00][00] [69][00][00][00] [6E][00][00][00] [73][00][00][00]
'    [20][00][00][00] [74][00][00][00] [77][00][00][00] [6F][00][00][00]
'    [20][00][00][00] [63][00][00][00] [68][00][00][00] [61][00][00][00]
'    [72][00][00][00] [61][00][00][00] [63][00][00][00] [74][00][00][00]
'    [65][00][00][00] [72][00][00][00] [73][00][00][00] [20][00][00][00]
'    [77][00][00][00] [69][00][00][00] [74][00][00][00] [68][00][00][00]
'    [20][00][00][00] [63][00][00][00] [6F][00][00][00] [64][00][00][00]
'    [65][00][00][00] [73][00][00][00] [20][00][00][00] [6F][00][00][00]
'    [75][00][00][00] [74][00][00][00] [73][00][00][00] [69][00][00][00]
'    [64][00][00][00] [65][00][00][00] [20][00][00][00] [74][00][00][00]
'    [68][00][00][00] [65][00][00][00] [20][00][00][00] [41][00][00][00]
'    [53][00][00][00] [43][00][00][00] [49][00][00][00] [49][00][00][00]
'    [20][00][00][00] [63][00][00][00] [6F][00][00][00] [64][00][00][00]
'    [65][00][00][00] [20][00][00][00] [72][00][00][00] [61][00][00][00]
'    [6E][00][00][00] [67][00][00][00] [65][00][00][00] [3A][00][00][00]
'    [20][00][00][00] [50][00][00][00] [69][00][00][00] [20][00][00][00]
'    [28][00][00][00] [A0][03][00][00] [29][00][00][00] [20][00][00][00]
'    [61][00][00][00] [6E][00][00][00] [64][00][00][00] [20][00][00][00]
'    [53][00][00][00] [69][00][00][00] [67][00][00][00] [6D][00][00][00]
'    [61][00][00][00] [20][00][00][00] [28][00][00][00] [A3][03][00][00]
'    [29][00][00][00] [2E][00][00][00]
'
'    Decoded string:
'       This string contains two characters with codes outside the ASCII code range:
'    Pi (π) and Sigma (Σ).

다음 예제에서는 인코딩된 바이트를 파일에 쓰고 바이트 스트림에 BOM(바이트 순서 표시)을 접두사로 추가한다는 점을 제외하고 이전 문자열과 동일한 문자열을 사용합니다. 그런 다음 두 가지 방법으로 파일을 읽습니다. 즉, 개체를 사용하여 StreamReader 텍스트 파일로, 이진 파일로 읽습니다. 예상대로 새로 읽은 문자열에는 BOM이 포함되어 있지 않습니다.

using System;
using System.IO;
using System.Text;

public class Example
{
    public static void Main()
    {
        // Create a UTF-32 encoding that supports a BOM.
        var enc = new UTF32Encoding();
        
        // A Unicode string with two characters outside an 8-bit code range.
        String s = "This Unicode string has 2 characters " +
                   "outside the ASCII range: \n" +
                   "Pi (\u03A0), and Sigma (\u03A3).";
        Console.WriteLine("Original string:");
        Console.WriteLine(s);
        Console.WriteLine();
        
        // Encode the string.
        Byte[] encodedBytes = enc.GetBytes(s);
        Console.WriteLine("The encoded string has {0} bytes.\n",
                          encodedBytes.Length);

        // Write the bytes to a file with a BOM.
        var fs = new FileStream(@".\UTF32Encoding.txt", FileMode.Create);
        Byte[] bom = enc.GetPreamble();
        fs.Write(bom, 0, bom.Length);
        fs.Write(encodedBytes, 0, encodedBytes.Length);
        Console.WriteLine("Wrote {0} bytes to the file.\n", fs.Length);
        fs.Close();

        // Open the file using StreamReader.
        var sr = new StreamReader(@".\UTF32Encoding.txt");
        String newString = sr.ReadToEnd();
        sr.Close();
        Console.WriteLine("String read using StreamReader:");
        Console.WriteLine(newString);
        Console.WriteLine();
        
        // Open the file as a binary file and decode the bytes back to a string.
        fs = new FileStream(@".\Utf32Encoding.txt", FileMode.Open);
        Byte[] bytes = new Byte[fs.Length];
        fs.Read(bytes, 0, (int)fs.Length);
        fs.Close();

        String decodedString = enc.GetString(bytes);
        Console.WriteLine("Decoded bytes from binary file:");
        Console.WriteLine(decodedString);
    }
}
// The example displays the following output:
//    Original string:
//    This Unicode string has 2 characters outside the ASCII range:
//    Pi (π), and Sigma (Σ).
//
//    The encoded string has 340 bytes.
//
//    Wrote 344 bytes to the file.
//
//    String read using StreamReader:
//    This Unicode string has 2 characters outside the ASCII range:
//    Pi (π), and Sigma (Σ).
//
//    Decoded bytes from binary file:
//    This Unicode string has 2 characters outside the ASCII range:
//    Pi (π), and Sigma (Σ).
Imports System.IO
Imports System.Text

Class Example
    Public Shared Sub Main()
        ' Create a UTF-32 encoding that supports a BOM.
        Dim enc As New UTF32Encoding()
        
        ' A Unicode string with two characters outside an 8-bit code range.
        Dim s As String = _
            "This Unicode string has 2 characters outside the " &
            "ASCII range: " & vbCrLf &
            "Pi (" & ChrW(&h03A0) & "), and Sigma (" & ChrW(&h03A3) & ")."
        Console.WriteLine("Original string:")
        Console.WriteLine(s)
        Console.WriteLine()
        
        ' Encode the string.
        Dim encodedBytes As Byte() = enc.GetBytes(s)
        Console.WriteLine("The encoded string has {0} bytes.",
                          encodedBytes.Length)
        Console.WriteLine()
        
        ' Write the bytes to a file with a BOM.
        Dim fs As New FileStream(".\UTF32Encoding.txt", FileMode.Create)
        Dim bom() As Byte = enc.GetPreamble()
        fs.Write(bom, 0, bom.Length)
        fs.Write(encodedBytes, 0, encodedBytes.Length)
        Console.WriteLine("Wrote {0} bytes to the file.", fs.Length)
        fs.Close()
        Console.WriteLine()
        
        ' Open the file using StreamReader.
        Dim sr As New StreamReader(".\UTF32Encoding.txt")
        Dim newString As String = sr.ReadToEnd()
        sr.Close()
        Console.WriteLine("String read using StreamReader:")
        Console.WriteLine(newString)
        Console.WriteLine()
        
        ' Open the file as a binary file and decode the bytes back to a string.
        fs = new FileStream(".\Utf32Encoding.txt", FileMode.Open)
        Dim bytes(fs.Length - 1) As Byte
        fs.Read(bytes, 0, fs.Length)
        fs.Close()

        Dim decodedString As String = enc.GetString(bytes)
        Console.WriteLine("Decoded bytes from binary file:")
        Console.WriteLine(decodedString)
    End Sub
End Class
' The example displays the following output:
'    Original string:
'    This Unicode string has 2 characters outside the ASCII range:
'    Pi (π), and Sigma (Σ).
'
'    The encoded string has 344 bytes.
'
'    Wrote 348 bytes to the file.
'
'    String read using StreamReader:
'    This Unicode string has 2 characters outside the ASCII range:
'    Pi (π), and Sigma (Σ).
'
'    Decoded bytes from binary file:
'    This Unicode string has 2 characters outside the ASCII range:
'    Pi (π), and Sigma (Σ).

설명

인코딩은 유니코드 문자 집합을 바이트 시퀀스로 변환하는 프로세스입니다. 디코딩은 인코딩된 바이트 시퀀스를 유니코드 문자 집합으로 변환하는 프로세스입니다.

유니코드 표준은 지원되는 모든 스크립트의 각 문자에 코드 포인트(숫자)를 할당합니다. UTF(유니코드 변환 형식)는 해당 코드 포인트를 인코딩하는 방법입니다. 유니코드 표준은 다음 UTF를 사용합니다.

  • UTF-8 - 각 코드 포인트를 1~4바이트 시퀀스로 나타냅니다.

  • UTF-16 - 각 코드 포인트를 1~2개의 16비트 정수 시퀀스로 나타냅니다.

  • UTF-32 - 각 코드 포인트를 32비트 정수로 나타냅니다.

에서 지원하는 System.TextUTF 및 기타 인코딩에 대한 자세한 내용은 .NET의 문자 인코딩을 참조하세요.

클래스는 UTF32Encoding UTF-32 인코딩을 나타냅니다. 인코더는 big endian 바이트 순서(가장 중요한 바이트 우선) 또는 작은 엔디안 바이트 순서(가장 낮은 바이트 우선)를 사용할 수 있습니다. 예를 들어 라틴어 대문자 A(코드 포인트 U+0041)는 다음과 같이 직렬화됩니다(16진수).

  • 빅 엔디안 바이트 주문: 00 00 00 41

  • Little endian 바이트 순서: 41 00 00 00

일반적으로 기본 바이트 순서를 사용 하 여 유니코드 문자를 저장 하는 것이 더 효율적입니다. 예를 들어 Intel 컴퓨터와 같은 little endian 플랫폼에서 little endian 바이트 순서를 사용 하는 것이 좋습니다. UTF32Encoding 는 Windows 코드 페이지 12000(little endian 바이트 순서) 및 12001(big endian 바이트 순서)에 해당합니다. 메서드를 호출 BitConverter.IsLittleEndian 하여 특정 아키텍처의 "endianness"를 확인할 수 있습니다.

필요에 따라 개체는 UTF32Encoding 인코딩 프로세스에서 발생하는 바이트 시퀀스에 접두사를 지정할 수 있는 바이트 배열인 BOM(바이트 순서 표시)을 제공합니다. 프리앰블에 BOM(바이트 순서 표시)이 포함된 경우 디코더가 바이트 순서와 바이트 배열의 변환 형식 또는 UTF를 결정하는 데 도움이 됩니다.

UTF32Encoding instance BOM을 제공하도록 구성된 경우 메서드를 호출 GetPreamble 하여 검색할 수 있습니다. 그렇지 않으면 메서드가 빈 배열을 반환합니다. 개체가 UTF32Encoding BOM 지원을 위해 구성된 경우에도 인코딩된 바이트 스트림의 시작 부분에 BOM을 적절하게 포함해야 합니다. 클래스의 UTF32Encoding 인코딩 메서드는 이 작업을 자동으로 수행하지 않습니다.

주의

오류 검색을 사용하도록 설정하고 클래스 instance 보안을 강화하려면 생성자를 호출 UTF32Encoding(Boolean, Boolean, Boolean) 하고 해당 인수trueUTF32Encoding 로 설정하여 개체를 throwOnInvalidBytes 인스턴스화해야 합니다. 오류 검색을 사용하면 잘못된 문자 또는 바이트 시퀀스를 검색하는 메서드가 예외를 ArgumentException throw합니다. 오류 검색이 없으면 예외가 throw되지 않으며 잘못된 시퀀스는 일반적으로 무시됩니다.

개체가 UTF32Encoding BOM(바이트 순서 표시)을 제공할지 여부, big-endian 또는 little-endian 인코딩을 원하는지 여부, 오류 검색을 사용하도록 설정할지 여부에 따라 여러 가지 방법으로 개체를 인스턴스화할 수 있습니다. 다음 표에는 개체를 반환하는 UTF32Encoding 생성자와 Encoding 속성이 나열되어 있습니다 UnicodeEncoding .

멤버 endian BOM 오류 검색
Encoding.UTF32 리틀 엔디안 Yes 아니요(대체 대체)
UTF32Encoding.UTF32Encoding() 리틀 엔디안 아니요(대체 대체)
UTF32Encoding.UTF32Encoding(Boolean, Boolean) 구성 가능 구성 가능 아니요(대체 대체)
UTF32Encoding.UTF32Encoding(Boolean, Boolean, Boolean) 구성 가능 구성 가능 구성 가능

GetByteCount메서드는 유니코드 문자 집합을 인코딩할 바이트 수를 결정 하 고 GetBytes 메서드는 실제 인코딩을 수행 합니다.

마찬가지로 메서드는 GetCharCount 바이트 GetChars 시퀀스를 디코딩하는 결과 문자 수를 결정하고 및 GetString 메서드는 실제 디코딩을 수행합니다.

여러 블록에 걸쳐 있는 데이터를 인코딩하거나 디코딩할 때 상태 정보를 저장할 수 있는 인코더 또는 디코더(예: 100,000자 세그먼트로 인코딩된 100만 문자 문자열)의 경우 각각 및 GetDecoder 속성을 사용합니다GetEncoder.

생성자

UTF32Encoding()

UTF32Encoding 클래스의 새 인스턴스를 초기화합니다.

UTF32Encoding(Boolean, Boolean)

UTF32Encoding 클래스의 새 인스턴스를 초기화합니다. 매개 변수를 사용하여 big endian 바이트 순서를 사용할지 여부와 GetPreamble() 메서드를 통해 유니코드 바이트 순서 표시를 반환할지 여부를 지정할 수 있습니다.

UTF32Encoding(Boolean, Boolean, Boolean)

UTF32Encoding 클래스의 새 인스턴스를 초기화합니다. 매개 변수를 사용하여 big endian 바이트 순서를 사용할지 여부, 유니코드 바이트 순서 표시를 제공할지 여부 및 잘못된 인코딩이 검색되었을 때 예외를 발생시킬지 여부를 지정할 수 있습니다.

속성

BodyName

파생 클래스에서 재정의되면 메일 에이전트 본문 태그에 사용할 수 있는 현재 인코딩의 이름을 가져옵니다.

(다음에서 상속됨 Encoding)
CodePage

파생 클래스에서 재정의되면 현재 Encoding의 코드 페이지 식별자를 가져옵니다.

(다음에서 상속됨 Encoding)
DecoderFallback

현재 DecoderFallback 개체에 대한 Encoding 개체를 가져오거나 설정합니다.

(다음에서 상속됨 Encoding)
EncoderFallback

현재 EncoderFallback 개체에 대한 Encoding 개체를 가져오거나 설정합니다.

(다음에서 상속됨 Encoding)
EncodingName

파생 클래스에서 재정의되면 현재 인코딩에 대해 사람이 읽을 수 있는 설명을 가져옵니다.

(다음에서 상속됨 Encoding)
HeaderName

파생 클래스에서 재정의되면 메일 에이전트 헤더 태그에 사용할 수 있는 현재 인코딩의 이름을 가져옵니다.

(다음에서 상속됨 Encoding)
IsBrowserDisplay

파생 클래스에서 재정의되면 현재 인코딩을 브라우저 클라이언트가 내용을 표시하는 데 사용할 수 있는지를 나타내는 값을 가져옵니다.

(다음에서 상속됨 Encoding)
IsBrowserSave

파생 클래스에서 재정의되면 현재 인코딩을 브라우저 클라이언트가 내용을 저장하는 데 사용할 수 있는지를 나타내는 값을 가져옵니다.

(다음에서 상속됨 Encoding)
IsMailNewsDisplay

파생 클래스에서 재정의되면 현재 인코딩을 메일 및 뉴스 클라이언트가 내용을 표시하는 데 사용할 수 있는지를 나타내는 값을 가져옵니다.

(다음에서 상속됨 Encoding)
IsMailNewsSave

파생 클래스에서 재정의되면 현재 인코딩을 메일 및 뉴스 클라이언트가 내용을 저장하는 데 사용할 수 있는지를 나타내는 값을 가져옵니다.

(다음에서 상속됨 Encoding)
IsReadOnly

파생 클래스에서 재정의되면 현재 인코딩이 읽기 전용인지를 나타내는 값을 가져옵니다.

(다음에서 상속됨 Encoding)
IsSingleByte

파생 클래스에서 재정의되면 현재 인코딩이 단일 바이트 코드 포인트를 사용하는지를 나타내는 값을 가져옵니다.

(다음에서 상속됨 Encoding)
Preamble

개체가 하나를 제공하도록 구성된 경우 UTF-32 형식으로 인코딩된 유니코드 바이트 순서 표시를 가져옵니다.

Preamble

파생 클래스에서 재정의할 경우, 사용된 인코딩을 지정하는 바이트 시퀀스를 포함하는 범위를 반환합니다.

(다음에서 상속됨 Encoding)
WebName

파생 클래스에서 재정의되면 현재 인코딩에 대해 IANA(Internet Assigned Numbers Authority)에 등록된 이름을 가져옵니다.

(다음에서 상속됨 Encoding)
WindowsCodePage

파생 클래스에서 재정의되면 현재 인코딩과 가장 비슷한 Windows 운영 체제 코드 페이지를 가져옵니다.

(다음에서 상속됨 Encoding)

메서드

Clone()

파생 클래스에서 재정의되면 현재 Encoding 개체의 부분 복사본을 만듭니다.

(다음에서 상속됨 Encoding)
Equals(Object)

지정한 Object이(가) 현재 UTF32Encoding 개체와 같은지 여부를 확인합니다.

GetByteCount(Char*, Int32)

지정한 문자 포인터에서 시작되는 문자 집합을 인코딩할 경우 생성되는 바이트 수를 계산합니다.

GetByteCount(Char[])

파생 클래스에서 재정의되면 지정한 문자 배열의 모든 문자를 인코딩하여 생성되는 바이트 수를 계산합니다.

(다음에서 상속됨 Encoding)
GetByteCount(Char[], Int32, Int32)

지정한 문자 배열의 문자 집합을 인코딩할 경우 생성되는 바이트 수를 계산합니다.

GetByteCount(ReadOnlySpan<Char>)

파생 클래스에서 재정의할 경우, 지정된 문자 범위의 문자를 인코딩하여 생성되는 바이트 수를 계산합니다.

(다음에서 상속됨 Encoding)
GetByteCount(String)

지정된 String의 문자를 인코딩하여 생성된 바이트 수를 계산합니다.

GetByteCount(String, Int32, Int32)

파생 클래스에서 재정의할 경우, 지정된 문자열의 문자 집합을 인코딩하여 생성되는 바이트 수를 계산합니다.

(다음에서 상속됨 Encoding)
GetBytes(Char*, Int32, Byte*, Int32)

지정한 문자 포인터에서 시작하는 문자 집합을 지정한 바이트 포인터에서 시작하여 저장되는 바이트 시퀀스로 인코딩합니다.

GetBytes(Char[])

파생 클래스에서 재정의되면 지정한 문자 배열의 모든 문자를 바이트 시퀀스로 인코딩합니다.

(다음에서 상속됨 Encoding)
GetBytes(Char[], Int32, Int32)

파생 클래스에서 재정의되면 지정한 문자 배열의 문자 집합을 바이트 시퀀스로 인코딩합니다.

(다음에서 상속됨 Encoding)
GetBytes(Char[], Int32, Int32, Byte[], Int32)

지정한 문자 배열의 문자 집합을 지정한 바이트 배열로 인코딩합니다.

GetBytes(ReadOnlySpan<Char>, Span<Byte>)

파생 클래스에서 재정의할 경우, 지정된 읽기 전용 범위의 문자 집합을 바이트 범위로 인코딩합니다.

(다음에서 상속됨 Encoding)
GetBytes(String)

파생 클래스에서 재정의되면 지정한 문자열의 모든 문자를 바이트 시퀀스로 인코딩합니다.

(다음에서 상속됨 Encoding)
GetBytes(String, Int32, Int32)

파생 클래스에서 재정의할 경우, 지정된 index에서 시작하여 지정한 문자열 내에서 count로 지정된 문자의 수를 바이트 배결로 인코딩합니다.

(다음에서 상속됨 Encoding)
GetBytes(String, Int32, Int32, Byte[], Int32)

지정된 String의 문자 집합을 지정된 바이트 배열로 인코딩합니다.

GetCharCount(Byte*, Int32)

지정한 바이트 포인터에서 시작되는 바이트 시퀀스를 디코딩할 경우 생성되는 문자 수를 계산합니다.

GetCharCount(Byte[])

파생 클래스에서 재정의되면 지정한 바이트 배열의 모든 바이트를 디코딩하여 생성되는 문자 수를 계산합니다.

(다음에서 상속됨 Encoding)
GetCharCount(Byte[], Int32, Int32)

지정한 바이트 배열의 바이트 시퀀스를 디코딩할 경우 생성되는 문자 수를 계산합니다.

GetCharCount(ReadOnlySpan<Byte>)

파생 클래스에서 재정의할 경우, 제공된 읽기 전용 바이트 범위를 디코딩하여 생성되는 문자 수를 계산합니다.

(다음에서 상속됨 Encoding)
GetChars(Byte*, Int32, Char*, Int32)

지정한 바이트 포인터에서 시작하는 바이트 시퀀스를 지정한 문자 포인터에서 시작하여 저장되는 문자 집합으로 디코딩합니다.

GetChars(Byte[])

파생 클래스에서 재정의되면 지정한 바이트 배열의 모든 바이트를 문자 집합으로 디코딩합니다.

(다음에서 상속됨 Encoding)
GetChars(Byte[], Int32, Int32)

파생 클래스에서 재정의되면 지정한 바이트 배열의 바이트 시퀀스를 문자 집합으로 디코딩합니다.

(다음에서 상속됨 Encoding)
GetChars(Byte[], Int32, Int32, Char[], Int32)

지정한 바이트 배열의 바이트 시퀀스를 지정한 문자 배열로 디코딩합니다.

GetChars(ReadOnlySpan<Byte>, Span<Char>)

파생 클래스에서 재정의할 경우, 지정된 읽기 전용 바이트 범위의 모든 바이트를 문자 범위로 디코딩합니다.

(다음에서 상속됨 Encoding)
GetDecoder()

UTF-32로 인코딩된 바이트 시퀀스를 유니코드 문자 시퀀스로 변환하는 디코더를 가져옵니다.

GetEncoder()

유니코드 문자 시퀀스를 UTF-32로 인코딩된 바이트 시퀀스로 변환하는 인코더를 가져옵니다.

GetHashCode()

현재 인스턴스의 해시 코드를 반환합니다.

GetMaxByteCount(Int32)

지정한 수의 문자를 인코딩할 경우 생성되는 최대 바이트 수를 계산합니다.

GetMaxCharCount(Int32)

지정한 수의 바이트를 디코딩할 경우 생성되는 최대 문자 수를 계산합니다.

GetPreamble()

UTF32Encoding 개체가 제공하도록 구성된 경우 UTF-32 형식으로 인코딩된 유니코드 바이트 순서 표시를 반환합니다.

GetString(Byte*, Int32)

파생 클래스에서 재정의할 때 지정된 주소에서 시작하는 지정된 바이트 수를 문자열로 디코딩합니다.

(다음에서 상속됨 Encoding)
GetString(Byte[])

파생 클래스에서 재정의되면 지정한 바이트 배열의 모든 바이트를 문자열로 디코딩합니다.

(다음에서 상속됨 Encoding)
GetString(Byte[], Int32, Int32)

바이트 배열의 바이트 범위를 문자열로 디코딩합니다.

GetString(ReadOnlySpan<Byte>)

파생 클래스에서 재정의할 경우, 지정된 바이트 범위의 모든 바이트를 문자열로 디코딩합니다.

(다음에서 상속됨 Encoding)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
IsAlwaysNormalized()

기본 정규화 형식을 사용하여 현재 인코딩이 항상 정규화되는지를 나타내는 값을 가져옵니다.

(다음에서 상속됨 Encoding)
IsAlwaysNormalized(NormalizationForm)

파생 클래스에서 재정의되면 지정한 정규화 형식을 사용하여 현재 인코딩이 항상 정규화되는지를 나타내는 값을 가져옵니다.

(다음에서 상속됨 Encoding)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)
TryGetBytes(ReadOnlySpan<Char>, Span<Byte>, Int32)

대상이 충분히 큰 경우 지정된 읽기 전용 범위의 문자 집합을 바이트 범위로 인코딩합니다.

(다음에서 상속됨 Encoding)
TryGetChars(ReadOnlySpan<Byte>, Span<Char>, Int32)

대상이 충분히 큰 경우 지정된 읽기 전용 범위에서 바이트 집합을 chars 범위로 디코딩합니다.

(다음에서 상속됨 Encoding)

확장 메서드

GetBytes(Encoding, ReadOnlySequence<Char>)

지정된 Encoding을 사용하여 지정된 ReadOnlySequence<T>Byte 배열로 인코딩합니다.

GetBytes(Encoding, ReadOnlySequence<Char>, IBufferWriter<Byte>)

지정된 Encoding을 사용하여 지정된 ReadOnlySequence<T>byte로 디코딩하고 결과를 writer에 씁니다.

GetBytes(Encoding, ReadOnlySequence<Char>, Span<Byte>)

지정된 Encoding을 사용하여 지정된 ReadOnlySequence<T>byte로 인코딩하고 결과를 bytes에 출력합니다.

GetBytes(Encoding, ReadOnlySpan<Char>, IBufferWriter<Byte>)

지정된 Encoding을 사용하여 지정된 ReadOnlySpan<T>byte로 인코딩하고 결과를 writer에 씁니다.

GetChars(Encoding, ReadOnlySequence<Byte>, IBufferWriter<Char>)

지정된 Encoding을 사용하여 지정된 ReadOnlySequence<T>char로 디코딩하고 결과를 writer에 씁니다.

GetChars(Encoding, ReadOnlySequence<Byte>, Span<Char>)

지정된 Encoding을 사용하여 지정된 ReadOnlySequence<T>char로 디코딩하고 결과를 chars에 출력합니다.

GetChars(Encoding, ReadOnlySpan<Byte>, IBufferWriter<Char>)

지정된 Encoding을 사용하여 지정된 ReadOnlySpan<T>char로 디코딩하고 결과를 writer에 씁니다.

GetString(Encoding, ReadOnlySequence<Byte>)

지정된 Encoding을 사용하여 지정된 ReadOnlySequence<T>String으로 디코딩합니다.

적용 대상

추가 정보