UTF7Encoding 생성자

정의

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

오버로드

Name Description
UTF7Encoding()
사용되지 않음.

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

UTF7Encoding(Boolean)
사용되지 않음.

UTF7Encoding 클래스의 새 인스턴스를 초기화합니다. 매개 변수는 선택적 문자를 허용할지 여부를 지정합니다.

UTF7Encoding()

Source:
UTF7Encoding.cs
Source:
UTF7Encoding.cs
Source:
UTF7Encoding.cs
Source:
UTF7Encoding.cs
Source:
UTF7Encoding.cs

주의

The UTF-7 encoding is insecure and should not be used. Consider using UTF-8 instead.

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

public:
 UTF7Encoding();
public UTF7Encoding();
[System.Obsolete("The UTF-7 encoding is insecure and should not be used. Consider using UTF-8 instead.", DiagnosticId="SYSLIB0001", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public UTF7Encoding();
Public Sub New ()
특성

예제

다음 코드 예제에서는 새 UTF7Encoding 인스턴스를 만들고 인코딩의 이름을 표시하는 방법을 보여 줍니다.

using System;
using System.Text;

class UTF7EncodingExample {
    public static void Main() {
        UTF7Encoding utf7 = new UTF7Encoding();
        String encodingName = utf7.EncodingName;
        Console.WriteLine("Encoding name: " + encodingName);
    }
}
Imports System.Text

Class UTF7EncodingExample
    
    Public Shared Sub Main()
        Dim utf7 As New UTF7Encoding()
        Dim encodingName As String = utf7.EncodingName
        Console.WriteLine("Encoding name: " & encodingName)
    End Sub
End Class

설명

이 생성자는 선택적 문자를 허용하지 않는 인스턴스를 만듭니다. UTF7Encoding 생성자를 호출하는 것은 매개 변수를 UTF7Encoding.UTF7Encoding(Boolean) 사용하는 allowOptionals 생성자를 호출하고 해당 매개 변수를 지정하는 것과 false 같습니다.

인스턴스에서 선택적 문자를 허용하는 경우 유니코드 코드 포인트는 수정된 Base 64 문자 대신 해당 선택적 문자로 인코딩됩니다. 선택적 문자는 느낌표("!"), 뒤로 슬래시("\"), 세로선("|"), 큰따옴표("""), 숫자 기호("#"), 달러 기호("$"), 백분율 기호("%"), 앰퍼샌드("&"), 별표("*"), 세미콜론(";"), 왼쪽 꺾쇠괄호입니다. (""<), 오른쪽 꺾쇠 괄호("">), 왼쪽 중괄호("{"), 오른쪽 중괄호("}"), 왼쪽 대괄호("["), 오른쪽 대괄호("]"), 등호("="), 기호("@"), 외경 악센트("^"), 밑줄("_"), 밑줄("_") 및 괄호(""").

메모

UTF7Encoding에서는 오류 감지를 제공하지 않습니다. 보안상의 이유로 애플리케이션은 오류 검색을 사용UTF8EncodingUnicodeEncoding하거나 UTF32Encoding 사용하도록 설정하는 것이 좋습니다.

적용 대상

UTF7Encoding(Boolean)

Source:
UTF7Encoding.cs
Source:
UTF7Encoding.cs
Source:
UTF7Encoding.cs
Source:
UTF7Encoding.cs
Source:
UTF7Encoding.cs

주의

The UTF-7 encoding is insecure and should not be used. Consider using UTF-8 instead.

UTF7Encoding 클래스의 새 인스턴스를 초기화합니다. 매개 변수는 선택적 문자를 허용할지 여부를 지정합니다.

public:
 UTF7Encoding(bool allowOptionals);
public UTF7Encoding(bool allowOptionals);
[System.Obsolete("The UTF-7 encoding is insecure and should not be used. Consider using UTF-8 instead.", DiagnosticId="SYSLIB0001", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public UTF7Encoding(bool allowOptionals);
new System.Text.UTF7Encoding : bool -> System.Text.UTF7Encoding
[<System.Obsolete("The UTF-7 encoding is insecure and should not be used. Consider using UTF-8 instead.", DiagnosticId="SYSLIB0001", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
new System.Text.UTF7Encoding : bool -> System.Text.UTF7Encoding
Public Sub New (allowOptionals As Boolean)

매개 변수

allowOptionals
Boolean

true선택적 문자가 허용되도록 지정하려면 다음을 수행합니다. 그렇지 않으면 . false

특성

예제

다음 코드 예제에서는 선택적 문자를 허용하는 새 UTF7Encoding 인스턴스를 만드는 방법을 보여 줍니다.

using System;
using System.Text;

class UTF7EncodingExample {
    public static void Main() {

        // A few optional characters.
        string chars = "!@#$";

        // The default Encoding does not allow optional characters.
        // Alternate byte values are used.
        UTF7Encoding utf7 = new UTF7Encoding();
        Byte[] bytes1 = utf7.GetBytes(chars);
        
        Console.WriteLine("Default UTF7 Encoding:");
        ShowArray(bytes1);

        // Convert back to characters.
        Console.WriteLine("Characters:");
        ShowArray(utf7.GetChars(bytes1));

        // Now, allow optional characters.
        // Optional characters are encoded with their normal code points.
        UTF7Encoding utf7AllowOptionals = new UTF7Encoding(true);
        Byte[] bytes2 = utf7AllowOptionals.GetBytes(chars);
        
        Console.WriteLine("UTF7 Encoding with optional characters allowed:");
        ShowArray(bytes2);

        // Convert back to characters.
        Console.WriteLine("Characters:");
        ShowArray(utf7AllowOptionals.GetChars(bytes2));
    }

    public static void ShowArray(Array theArray) {
        foreach (Object o in theArray) {
            Console.Write("[{0}]", o);
        }
        Console.WriteLine();
    }
}
Imports System.Text

Class UTF7EncodingExample
    
    Public Shared Sub Main()
        
        ' A few optional characters.
        Dim chars As String = "!@#$"
        
        ' The default Encoding does not allow optional characters.
        ' Alternate byte values are used.
        Dim utf7 As New UTF7Encoding()
        Dim bytes1 As Byte() = utf7.GetBytes(chars)
        
        Console.WriteLine("Default UTF7 Encoding:")
        ShowArray(bytes1)
        
        ' Convert back to characters.
        Console.WriteLine("Characters:")
        ShowArray(utf7.GetChars(bytes1))
        
        ' Now, allow optional characters.
        ' Optional characters are encoded with their normal code points.
        Dim utf7AllowOptionals As New UTF7Encoding(True)
        Dim bytes2 As Byte() = utf7AllowOptionals.GetBytes(chars)
        
        Console.WriteLine("UTF7 Encoding with optional characters allowed:")
        ShowArray(bytes2)
        
        ' Convert back to characters.
        Console.WriteLine("Characters:")
        ShowArray(utf7AllowOptionals.GetChars(bytes2))
    End Sub
    
    
    Public Shared Sub ShowArray(theArray As Array)
        Dim o As Object
        For Each o In  theArray
            Console.Write("[{0}]", o)
        Next o
        Console.WriteLine()
    End Sub
End Class

설명

인스턴스에서 선택적 문자를 허용하는 경우 유니코드 코드 포인트는 수정된 Base 64 문자 대신 해당 선택적 문자로 인코딩됩니다. 선택적 문자는 느낌표("!"), 뒤로 슬래시("\"), 세로선("|"), 큰따옴표("""), 숫자 기호("#"), 달러 기호("$"), 백분율 기호("%"), 앰퍼샌드("&"), 별표("*"), 세미콜론(";"), 왼쪽 꺾쇠괄호입니다. (""<), 오른쪽 꺾쇠 괄호("">), 왼쪽 중괄호("{"), 오른쪽 중괄호("}"), 왼쪽 대괄호("["), 오른쪽 대괄호("]"), 등호("="), 기호("@"), 외경 악센트("^"), 밑줄("_"), 밑줄("_") 및 괄호(""").

메모

UTF7Encoding에서는 오류 감지를 제공하지 않습니다. 보안상의 이유로 애플리케이션은 오류 검색을 사용UTF8EncodingUnicodeEncoding하거나 UTF32Encoding 사용하도록 설정하는 것이 좋습니다.

적용 대상