Encoding 클래스

정의

문자 인코딩을 나타냅니다.

public ref class Encoding abstract
public ref class Encoding abstract : ICloneable
public abstract class Encoding
public abstract class Encoding : ICloneable
[System.Serializable]
public abstract class Encoding
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public abstract class Encoding : ICloneable
type Encoding = class
type Encoding = class
    interface ICloneable
[<System.Serializable>]
type Encoding = class
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type Encoding = class
    interface ICloneable
Public MustInherit Class Encoding
Public MustInherit Class Encoding
Implements ICloneable
상속
Encoding
파생
특성
구현

예제

다음 예제에서는 문자열을 한 인코딩에서 다른 인코딩으로 변환 합니다.

참고

byte[]배열은이 예제에서 인코딩된 데이터를 포함 하는 유일한 형식입니다. .NET CharString 형식은 자체 유니코드 이므로 GetChars 호출은 데이터를 다시 유니코드로 디코딩합니다.

using namespace System;
using namespace System::Text;

int main()
{
   String^ unicodeString = "This string contains the unicode character Pi (\u03a0)";
   
   // Create two different encodings.
   Encoding^ ascii = Encoding::ASCII;
   Encoding^ unicode = Encoding::Unicode;
   
   // Convert the string into a byte array.
   array<Byte>^unicodeBytes = unicode->GetBytes( unicodeString );
   
   // Perform the conversion from one encoding to the other.
   array<Byte>^asciiBytes = Encoding::Convert( unicode, ascii, unicodeBytes );
   
   // Convert the new Byte into[] a char and[] then into a string.
   array<Char>^asciiChars = gcnew array<Char>(ascii->GetCharCount( asciiBytes, 0, asciiBytes->Length ));
   ascii->GetChars( asciiBytes, 0, asciiBytes->Length, asciiChars, 0 );
   String^ asciiString = gcnew String( asciiChars );
   
   // Display the strings created before and after the conversion.
   Console::WriteLine( "Original String*: {0}", unicodeString );
   Console::WriteLine( "Ascii converted String*: {0}", asciiString );
}
// The example displays the following output:
//    Original string: This string contains the unicode character Pi (Π)
//    Ascii converted string: This string contains the unicode character Pi (?)
using System;
using System.Text;

class Example
{
   static void Main()
   {
      string unicodeString = "This string contains the unicode character Pi (\u03a0)";

      // Create two different encodings.
      Encoding ascii = Encoding.ASCII;
      Encoding unicode = Encoding.Unicode;

      // Convert the string into a byte array.
      byte[] unicodeBytes = unicode.GetBytes(unicodeString);

      // Perform the conversion from one encoding to the other.
      byte[] asciiBytes = Encoding.Convert(unicode, ascii, unicodeBytes);
         
      // Convert the new byte[] into a char[] and then into a string.
      char[] asciiChars = new char[ascii.GetCharCount(asciiBytes, 0, asciiBytes.Length)];
      ascii.GetChars(asciiBytes, 0, asciiBytes.Length, asciiChars, 0);
      string asciiString = new string(asciiChars);

      // Display the strings created before and after the conversion.
      Console.WriteLine("Original string: {0}", unicodeString);
      Console.WriteLine("Ascii converted string: {0}", asciiString);
   }
}
// The example displays the following output:
//    Original string: This string contains the unicode character Pi (Π)
//    Ascii converted string: This string contains the unicode character Pi (?)
Imports System.Text

Class Example
   Shared Sub Main()
      Dim unicodeString As String = "This string contains the unicode character Pi (" & ChrW(&H03A0) & ")"

      ' Create two different encodings.
      Dim ascii As Encoding = Encoding.ASCII
      Dim unicode As Encoding = Encoding.Unicode

      ' Convert the string into a byte array.
      Dim unicodeBytes As Byte() = unicode.GetBytes(unicodeString)

      ' Perform the conversion from one encoding to the other.
      Dim asciiBytes As Byte() = Encoding.Convert(unicode, ascii, unicodeBytes)

      ' Convert the new byte array into a char array and then into a string.
      Dim asciiChars(ascii.GetCharCount(asciiBytes, 0, asciiBytes.Length)-1) As Char
      ascii.GetChars(asciiBytes, 0, asciiBytes.Length, asciiChars, 0)
      Dim asciiString As New String(asciiChars)

      ' Display the strings created before and after the conversion.
      Console.WriteLine("Original string: {0}", unicodeString)
      Console.WriteLine("Ascii converted string: {0}", asciiString)
   End Sub
End Class
' The example displays the following output:
'    Original string: This string contains the unicode character Pi (Π)
'    Ascii converted string: This string contains the unicode character Pi (?)

설명

이 API에 대한 자세한 내용은 인코딩에 대한 추가 API 설명을 참조하세요.

생성자

Encoding()

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

Encoding(Int32)

지정한 코드 페이지에 해당하는 Encoding 클래스의 새 인스턴스를 초기화합니다.

Encoding(Int32, EncoderFallback, DecoderFallback)

지정된 인코더 및 디코더 대체 전략을 사용하여 지정된 코드 페이지에 해당하는 Encoding 클래스의 새 인스턴스를 초기화합니다.

속성

ASCII

ASCII(7비트) 문자 집합에 대한 인코딩을 가져옵니다.

BigEndianUnicode

big endian 바이트 순서를 사용하는 UTF-16 형식에 대한 인코딩을 가져옵니다.

BodyName

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

CodePage

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

DecoderFallback

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

Default

이 .NET 구현을 위한 기본 인코딩을 가져옵니다.

EncoderFallback

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

EncodingName

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

HeaderName

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

IsBrowserDisplay

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

IsBrowserSave

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

IsMailNewsDisplay

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

IsMailNewsSave

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

IsReadOnly

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

IsSingleByte

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

Latin1

Latin1 문자 집합(ISO-8859-1)에 대한 인코딩을 가져옵니다.

Preamble

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

Unicode

little endian 바이트 순서를 사용하는 UTF-16 형식에 대한 인코딩을 가져옵니다.

UTF32

little endian 바이트 순서를 사용하는 UTF-32 형식에 대한 인코딩을 가져옵니다.

UTF7
사용되지 않음.

UTF-7 형식에 대한 인코딩을 가져옵니다.

UTF8

UTF-8 형식에 대한 인코딩을 가져옵니다.

WebName

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

WindowsCodePage

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

메서드

Clone()

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

Convert(Encoding, Encoding, Byte[])

전체 바이트 배열의 인코딩을 변환합니다.

Convert(Encoding, Encoding, Byte[], Int32, Int32)

바이트 배열의 바이트 범위를 한 인코딩에서 다른 인코딩으로 변환합니다.

CreateTranscodingStream(Stream, Encoding, Encoding, Boolean)

Convert(Encoding, Encoding, Byte[])와 유사한, 내부 Encoding과 외부 Encoding 간에 데이터를 트랜스코딩하는 데 사용되는 Stream을 만듭니다.

Equals(Object)

지정한 Object가 현재 인스턴스와 같은지를 확인합니다.

GetByteCount(Char*, Int32)

파생 클래스에서 재정의되면 지정한 문자 포인터에서 시작하는 문자 집합을 인코딩하여 생성되는 바이트 수를 계산합니다.

GetByteCount(Char[])

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

GetByteCount(Char[], Int32, Int32)

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

GetByteCount(ReadOnlySpan<Char>)

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

GetByteCount(String)

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

GetByteCount(String, Int32, Int32)

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

GetBytes(Char*, Int32, Byte*, Int32)

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

GetBytes(Char[])

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

GetBytes(Char[], Int32, Int32)

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

GetBytes(Char[], Int32, Int32, Byte[], Int32)

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

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

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

GetBytes(String)

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

GetBytes(String, Int32, Int32)

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

GetBytes(String, Int32, Int32, Byte[], Int32)

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

GetCharCount(Byte*, Int32)

파생 클래스에서 재정의되면 지정한 바이트 포인터에서 시작하는 바이트 시퀀스를 디코딩하여 생성되는 문자 수를 계산합니다.

GetCharCount(Byte[])

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

GetCharCount(Byte[], Int32, Int32)

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

GetCharCount(ReadOnlySpan<Byte>)

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

GetChars(Byte*, Int32, Char*, Int32)

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

GetChars(Byte[])

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

GetChars(Byte[], Int32, Int32)

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

GetChars(Byte[], Int32, Int32, Char[], Int32)

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

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

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

GetDecoder()

파생 클래스에서 재정의되면 인코딩된 바이트 시퀀스를 문자 시퀀스로 변환하는 디코더를 가져옵니다.

GetEncoder()

파생 클래스에서 재정의되면 유니코드 문자 시퀀스를 인코딩된 바이트 시퀀스로 변환하는 인코더를 가져옵니다.

GetEncoding(Int32)

지정한 코드 페이지 식별자와 관련된 인코딩을 반환합니다.

GetEncoding(Int32, EncoderFallback, DecoderFallback)

지정한 코드 페이지 식별자와 관련된 인코딩을 반환합니다. 매개 변수는 인코딩할 수 없는 문자 및 디코딩할 수 없는 바이트 시퀀스에 대한 오류 처리기를 지정합니다.

GetEncoding(String)

지정한 코드 페이지 이름과 관련된 인코딩을 반환합니다.

GetEncoding(String, EncoderFallback, DecoderFallback)

지정한 코드 페이지 이름과 관련된 인코딩을 반환합니다. 매개 변수는 인코딩할 수 없는 문자 및 디코딩할 수 없는 바이트 시퀀스에 대한 오류 처리기를 지정합니다.

GetEncodings()

모든 인코딩을 포함하는 배열을 반환합니다.

GetHashCode()

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

GetMaxByteCount(Int32)

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

GetMaxCharCount(Int32)

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

GetPreamble()

파생 클래스에서 재정의되면 사용되는 인코딩을 지정하는 바이트 시퀀스를 반환합니다.

GetString(Byte*, Int32)

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

GetString(Byte[])

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

GetString(Byte[], Int32, Int32)

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

GetString(ReadOnlySpan<Byte>)

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

GetType()

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

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

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

IsAlwaysNormalized(NormalizationForm)

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

MemberwiseClone()

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

(다음에서 상속됨 Object)
RegisterProvider(EncodingProvider)

인코딩 공급자를 등록합니다.

ToString()

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

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

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

TryGetChars(ReadOnlySpan<Byte>, Span<Char>, Int32)

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

확장 메서드

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으로 디코딩합니다.

적용 대상

추가 정보