HttpUtility.HtmlDecode 메서드

정의

HTTP 전송을 위해 HTML로 인코딩된 문자열을 디코딩된 문자열로 변환합니다.

웹 애플리케이션 외부의 값을 인코딩 또는 디코딩하려면 WebUtility 클래스를 사용합니다.

오버로드

HtmlDecode(String)

HTTP 전송을 위해 HTML로 인코딩된 문자열을 디코딩된 문자열로 변환합니다.

HtmlDecode(String, TextWriter)

HTML로 인코딩된 문자열을 디코딩된 문자열로 변환하고 디코딩된 문자열을 TextWriter 출력 스트림으로 보냅니다.

HtmlDecode(String)

HTTP 전송을 위해 HTML로 인코딩된 문자열을 디코딩된 문자열로 변환합니다.

public:
 static System::String ^ HtmlDecode(System::String ^ s);
public static string? HtmlDecode (string? s);
public static string HtmlDecode (string s);
static member HtmlDecode : string -> string
Public Shared Function HtmlDecode (s As String) As String

매개 변수

s
String

디코딩할 문자열입니다.

반환

String

디코딩된 문자열입니다.

예제

다음 코드 예제에서는 클래스의 HtmlEncode 메서드와 HtmlDecode 메서드를 HttpUtility 보여 줍니다. 입력 문자열은 메서드를 사용하여 인코딩됩니다 HtmlEncode . 가져온 인코딩된 문자열은 메서드를 HtmlDecode 사용하여 디코딩됩니다.

using System;
using System.Web;
using System.IO;

class MyNewClass
{
    public static void Main()
    {
        Console.WriteLine("Enter a string having '&', '<', '>' or '\"' in it: ");
        string myString = Console.ReadLine();

        // Encode the string.
        string myEncodedString = HttpUtility.HtmlEncode(myString);

        Console.WriteLine($"HTML Encoded string is: {myEncodedString}");
        StringWriter myWriter = new StringWriter();

        // Decode the encoded string.
        HttpUtility.HtmlDecode(myEncodedString, myWriter);

        string myDecodedString = myWriter.ToString();
        Console.Write($"Decoded string of the above encoded string is: {myDecodedString}");
    }
}
Imports System.Web
Imports System.IO

Class MyNewClass
   Public Shared Sub Main()
      Dim myString As String
      Console.WriteLine("Enter a string having '&' or '""'  in it: ")
      myString = Console.ReadLine()
      Dim myEncodedString As String
      ' Encode the string.
      myEncodedString = HttpUtility.HtmlEncode(myString)
      Console.WriteLine("HTML Encoded string is " + myEncodedString)
      Dim myWriter As New StringWriter()
      ' Decode the encoded string.
      HttpUtility.HtmlDecode(myEncodedString, myWriter)
      Console.Write("Decoded string of the above encoded string is " + myWriter.ToString())
   End Sub
End Class

설명

공백 및 문장 부호와 같은 문자가 HTTP 스트림에 전달되면 수신 끝에서 잘못 해석될 수 있습니다. HTML 인코딩은 HTML에서 허용되지 않는 문자를 문자 엔터티로 변환합니다. HTML 디코딩은 인코딩을 반대로 합니다. 예를 들어 텍스트 블록에 포함된 경우 문자 < and > 는 HTTP 전송에 &lt; &gt; 대해 인코딩됩니다.

웹 애플리케이션 외부의 값을 인코딩 또는 디코딩하려면 WebUtility 클래스를 사용합니다.

추가 정보

적용 대상

HtmlDecode(String, TextWriter)

HTML로 인코딩된 문자열을 디코딩된 문자열로 변환하고 디코딩된 문자열을 TextWriter 출력 스트림으로 보냅니다.

public:
 static void HtmlDecode(System::String ^ s, System::IO::TextWriter ^ output);
public static void HtmlDecode (string? s, System.IO.TextWriter output);
public static void HtmlDecode (string s, System.IO.TextWriter output);
static member HtmlDecode : string * System.IO.TextWriter -> unit
Public Shared Sub HtmlDecode (s As String, output As TextWriter)

매개 변수

s
String

디코딩할 문자열입니다.

output
TextWriter

TextWriter 출력 스트림입니다.

설명

공백 및 문장 부호와 같은 문자가 HTTP 스트림에 전달되면 수신 끝에서 잘못 해석될 수 있습니다. HTML 인코딩은 HTML에서 허용되지 않는 문자를 문자 엔터티로 변환합니다. HTML 디코딩은 인코딩을 반대로 합니다. 예를 들어 텍스트 블록에 포함된 경우 문자 < and > 는 HTTP 전송에 &lt; &gt; 대해 인코딩됩니다.

웹 애플리케이션 외부의 값을 인코딩 또는 디코딩하려면 WebUtility 클래스를 사용합니다.

추가 정보

적용 대상