HttpServerUtility.HtmlDecode 메서드
정의
잘못된 HTML 문자를 제거하기 위해 인코딩된 문자열을 디코딩합니다.Decodes a string that has been encoded to eliminate invalid HTML characters.
웹 애플리케이션 외부의 값을 인코딩 또는 디코딩하려면 WebUtility 클래스를 사용합니다.To encode or decode values outside of a web application, use the WebUtility class.
오버로드
HtmlDecode(String) |
HTML로 인코딩된 문자열을 디코딩하여 디코딩된 문자열을 반환합니다.Decodes an HTML-encoded string and returns the decoded string. |
HtmlDecode(String, TextWriter) |
HTML로 인코딩된 문자열을 디코딩하고 그 결과 출력을 TextWriter 출력 스트림에 보냅니다.Decodes an HTML-encoded string and sends the resulting output to a TextWriter output stream. |
HtmlDecode(String)
HTML로 인코딩된 문자열을 디코딩하여 디코딩된 문자열을 반환합니다.Decodes an HTML-encoded string and returns the decoded string.
public:
System::String ^ HtmlDecode(System::String ^ s);
public string HtmlDecode (string s);
member this.HtmlDecode : string -> string
Public Function HtmlDecode (s As String) As String
매개 변수
- s
- String
디코딩할 HTML 문자열입니다.The HTML string to decode.
반환
디코딩된 텍스트입니다.The decoded text.
예제
함수를 포함 하는 다음 예제에서는 LoadDecodedFile
에 파일에서 데이터를 디코딩하고을 하나의 문자열로 복사 합니다.The following example contains the function LoadDecodedFile
, which decodes the data from a file and copies it into one string.
<%@ PAGE LANGUAGE = "C#" %>
<%@ IMPORT NAMESPACE = "System.IO" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<script runat ="server">
String LoadDecodedFile(String file)
{
String DecodedString = "";
FileStream fs = new FileStream(file, FileMode.Open);
StreamReader r = new StreamReader(fs);
// Position the file pointer at the beginning of the file.
r.BaseStream.Seek(0, SeekOrigin.Begin);
// Read the entire file into a string and decode each chunk.
while (r.Peek() > -1)
DecodedString += Server.HtmlDecode(r.ReadLine());
r.Close();
return DecodedString;
}
</script>
<head runat="server">
<title>HttpServerUtility.HtmlDecode Example</title>
</head>
<body></body>
</html>
<%@ PAGE LANGUAGE = "VB" %>
<%@ Import Namespace="System.IO" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<script runat = "server">
Function LoadDecodedFile(file As String) As String
Dim DecodedString As String
Dim fs As New FileStream(file, FileMode.Open)
Dim r As New StreamReader(fs)
' Position the file pointer at the beginning of the file.
r.BaseStream.Seek(0, SeekOrigin.Begin)
' Read the entire file into a string and decode each chunk.
Do While r.Peek() > -1
DecodedString = DecodedString & _
Server.HtmlDecode(r.ReadLine())
Loop
r.Close()
LoadDecodedFile = DecodedString
End Function
</script>
<head runat="server">
<title> HttpServerUtility.HtmlDecode Example</title>
</head>
<body></body>
</html>
설명
HTML 인코딩을 사용 하면 텍스트 HTML로 브라우저에서 해석 되지 않는 브라우저에서 올바르게 표시 하 합니다.HTML encoding makes sure that text is displayed correctly in the browser and not interpreted by the browser as HTML. 예를 들어, 보다 작음 기호를 포함 하는 텍스트 문자열 (<) 이상 기호 (>), 보다 브라우저는 HTML 태그의 닫는 괄호 또는 여 이러한 문자를 해석 합니다.For example, if a text string contains a less than sign (<) or greater than sign (>), the browser would interpret these characters as the opening or closing bracket of an HTML tag. 문자를 HTML로 인코딩된 경우 문자열로 변환 됩니다 <
및 >
, 기호 및 보다 보다 작음 기호 올바르게 표시 하려면 브라우저에 이르게 합니다.When the characters are HTML encoded, they are converted to the strings <
and >
, which causes the browser to display the less than sign and greater than sign correctly. HtmlDecode 서버에 전송 된 텍스트를 디코딩합니다.HtmlDecode decodes text that has been transmitted to the server.
이 방법은 편리 하 게 액세스를 HttpUtility.HtmlDecode ASP.NET 애플리케이션에서 런타임 시 메서드.This method is a convenient way to access the HttpUtility.HtmlDecode method at run time from an ASP.NET application. 이 메서드는 내부적으로 HttpUtility.HtmlDecode 디코딩할 문자열입니다.Internally, this method uses HttpUtility.HtmlDecode to decode strings.
ASP.NET 웹 페이지에 대 한 코드 숨김 파일에서의 인스턴스에 액세스 합니다 HttpServerUtility 를 통해 클래스는 Server
속성.In the code-behind file for an ASP.NET web page, access an instance of the HttpServerUtility class through the Server
property. 코드 숨김 파일에 없는 클래스에서 사용 하 여 HttpContext.Current.Server
의 인스턴스에 액세스 하는 HttpServerUtility 클래스입니다.In a class that is not in a code-behind file, use HttpContext.Current.Server
to access an instance of the HttpServerUtility class.
웹 애플리케이션을 외부에서 사용할는 WebUtility 인코딩 또는 디코딩하려면 값 클래스입니다.Outside of a web application, use the WebUtility class to encode or decode values.
HtmlDecode(String, TextWriter)
HTML로 인코딩된 문자열을 디코딩하고 그 결과 출력을 TextWriter 출력 스트림에 보냅니다.Decodes an HTML-encoded string and sends the resulting output to a TextWriter output stream.
public:
void HtmlDecode(System::String ^ s, System::IO::TextWriter ^ output);
public void HtmlDecode (string s, System.IO.TextWriter output);
member this.HtmlDecode : string * System.IO.TextWriter -> unit
Public Sub HtmlDecode (s As String, output As TextWriter)
매개 변수
- s
- String
디코딩할 HTML 문자열입니다.The HTML string to decode.
- output
- TextWriter
디코딩된 문자열을 포함하는 TextWriter 출력 스트림입니다.The TextWriter output stream that contains the decoded string.
예제
다음 예제에서는 된 전송을 위해 HTML로 인코딩된 HTTP를 통해 문자열로 디코딩합니다.The following example decodes a string that has been HTML-encoded for transmission over HTTP. 라는 제공된 된 문자열을 디코딩합니다 EncodedString
텍스트를 포함 하는 "이를 <테스트 문자열>.", 라는 문자열에 복사 DecodedString
으로 "이것이 <테스트 문자열 >."입니다.It decodes the supplied string named EncodedString
which contains the text "This is a <Test String>.", and copies it into the string named DecodedString
as "This is a <Test String>.".
String EncodedString = "This is a <Test String>.";
StringWriter writer = new StringWriter();
Server.HtmlDecode(EncodedString, writer);
String DecodedString = writer.ToString();
Dim EncodedString As String = "This is a <Test String>."
Dim writer As New StringWriter
Server.HtmlDecode(EncodedString, writer)
Dim DecodedString As String = writer.ToString()
설명
HTML 인코딩을 사용 하면 텍스트 HTML로 브라우저에서 해석 되지 않는 브라우저에서 올바르게 표시 하 합니다.HTML encoding makes sure that text is displayed correctly in the browser and not interpreted by the browser as HTML. 예를 들어, 보다 작음 기호를 포함 하는 텍스트 문자열 (<) 이상 기호 (>), 보다 브라우저는 HTML 태그의 닫는 괄호 또는 여 이러한 문자를 해석 합니다.For example, if a text string contains a less than sign (<) or greater than sign (>), the browser would interpret these characters as the opening or closing bracket of an HTML tag. 문자를 HTML로 인코딩된 경우 문자열로 변환 됩니다 <
및 >
, 기호 및 보다 보다 작음 기호 올바르게 표시 하려면 브라우저에 이르게 합니다.When the characters are HTML encoded, they are converted to the strings <
and >
, which causes the browser to display the less than sign and greater than sign correctly.
HtmlDecode 서버에 전송 된 텍스트를 디코딩합니다.HtmlDecode decodes text that has been transmitted to the server.
HtmlDecode 편리 하 게 액세스 되는 HttpUtility.HtmlDecode ASP.NET 애플리케이션에서 런타임에 메서드.HtmlDecode is a convenient way to access the HttpUtility.HtmlDecode method at run time from an ASP.NET application. 내부적으로 HtmlDecode 사용 하 여 HttpUtility.HtmlDecode 디코딩할 문자열입니다.Internally, HtmlDecode uses HttpUtility.HtmlDecode to decode strings.
웹 애플리케이션 외부의 값을 인코딩 또는 디코딩하려면 WebUtility 클래스를 사용합니다.To encode or decode values outside of a web application, use the WebUtility class.