티스토리 뷰
정보 보관 ver1.0
HttpServerUtility.HtmlEncode & HttpServerUtility.HtmlDecode
James Wetzel 2010. 8. 4. 20:07HttpServerUtility.HtmlEncode(=Server.HtmlEncode)
다음 예제에서는 HTTP로 전송할 문자열을 인코딩합니다.또한 텍스트 "This is a <Test String>."이 들어 있는 TestString이라는 문자열을 인코딩하고, 이를 EncodedString이라는 문자열에 "This is a <Test String>"으로 복사합니다.
String TestString = "This is a <Test String>.";
String EncodedString = Server.HtmlEncode(TestString);
String TestString = "This is a <Test String>.";
String EncodedString = Server.HtmlEncode(TestString);
HttpServerUtility.HtmlDecode(=Server.HtmlDecode)
URL을 인코딩하면 모든 브라우저에서 URL 문자열의 텍스트를 올바르게 전달할 수 있습니다.일부 브라우저에서는 물음표(?), 앰퍼샌드(&), 슬래시(/), 공백 등의 문자가 잘리거나 손상될 수 있습니다.따라서 이러한 문자는 <a> 태그로 인코딩하거나, 브라우저에서 문자열을 요청 문자열에 삽입하여 다시 보낼 수 있도록 쿼리 문자열로 인코딩해야 합니다.
<%@ PAGE LANGUAGE = "C#" %>
<%@ IMPORT NAMESPACE = "System.IO" %>
<%@ PAGE LANGUAGE = "C#" %>
<%@ IMPORT NAMESPACE = "System.IO" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<script runat ="server">
<script runat ="server">
String LoadDecodedFile(String file)
{
String DecodedString = "";
FileStream fs = new FileStream(file, FileMode.Open);
StreamReader r = new StreamReader(fs);
{
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);
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());
while (r.Peek() > -1)
DecodedString += Server.HtmlDecode(r.ReadLine());
r.Close();
return DecodedString;
}
return DecodedString;
}
</script>
<head runat="server">
<title>HttpServerUtility.HtmlDecode Example</title>
</head>
<body></body>
</html>
<head runat="server">
<title>HttpServerUtility.HtmlDecode Example</title>
</head>
<body></body>
</html>
728x90
반응형
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
TAG
- 제품 등록
- React
- jstl(java standard tag library)
- 스프링 시큐리티(spring security)-http basic 인증
- system.io
- System.Diagnostics
- 스프링 프레임워크(spring framework)
- In App Purchase
- .submit()
- java web-mvc
- 스프링 프레임워크(spring framewordk)
- nl2br
- java 키워드 정리
- 문자 자르기
- 메이븐(maven)
- 스프링 시큐리티(spring security)
- MainActor
- await
- java-개발 환경 설정하기
- 특정 문자를 기준으로 자르기
- docker
- jsp 오픈 소스
- 람다식(lambda expression)
- 진수 변환
- java.sql
- jstl(java standard tag library)-core
- error-java
- 인텔리제이(intellij)
- REST API
- 표현 언어(expression language)
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
글 보관함