일반 Escape special characters

황제낙엽 2010.10.28 13:19 조회 수 : 118 추천:105

sitelink1 http://www.javapractices.com/topic/TopicAction.do?Id=96 
sitelink2  
sitelink3  
sitelink4  
sitelink5  
sitelink6  

위 character들은 사용되는 언어에 따라 특수처리 되는 경우가 있다.
가령 '<' 는 < 로 변환 처리되어야 한다.
이것은 HTML, XML, RegEx 등등 각각의 언어에 따라 다르게 설정되기도 한다

다음은 원문
 


  • <
  • >
  • "
  • '
  •  
  • &



  •  
  • Arbitrary text placed in an HTML tag often needs to be altered, to ensure that the resulting HTML remains valid.

     

    Problem characters can include

    These characters can be replaced with HTML character entities. For example, < can be replaced with <.

    Query strings (Blah=1&Name=Bob) often need to be escaped as well. If the query string contains special characters, it will need to be "URL encoded". (See the javadoc for the URLEncoder class for further information.) This will ensure the query string conforms with valid HTTP.

    There is often a second issue, however, with regard to query strings. If a query string is placed in an HREF attribute, then even a URL encoded query string is often not of valid form. This is because URLEncoder produces valid HTTP, but it does not in general produce text which is a valid HTML attribute - the ampersand character needs to be replaced by the corresponding character entity &.

    Here is an example of a utility class which escapes special characters for HTML, XML, regular expressions, and so on.

     

     

     

     

    • <
    • >
    • "
    • '
    •  
    • &

     

     

번호 제목 글쓴이 날짜 조회 수
211 Hex string <-> String object 황제낙엽 2011.11.29 204
210 An alternative to the deep copy technique file 황제낙엽 2011.07.27 200
209 <jsp:include>, include지시자 file 황제낙엽 2011.07.24 145
208 <jsp:include> 액션태그 황제낙엽 2011.07.24 81
207 volatile 에 대한 단상(斷想) 황제낙엽 2011.06.22 58
206 Object element 의 onerror 이벤트 황제낙엽 2011.04.21 36
205 Java 2D Graphics - Reference link 황제낙엽 2011.04.11 90
204 deployJava.js를 이용한 JRE 자동설치 및 Applet 디플로이 file 황제낙엽 2011.04.04 701
203 Applet 의 모든것 황제낙엽 2011.04.01 306
202 Java Applets in HTML5 황제낙엽 2010.12.13 431
201 (Multiple Browser Supported) Java applet using XHTML 'object' tag 황제낙엽 2010.12.13 36
200 <Applet> 과 <Object> 종합 황제낙엽 2010.12.07 21
199 codebase 를 통한 autodownload 내용 황제낙엽 2010.12.07 507
198 오브젝트(object), 이미지와 애플렛(applet) 황제낙엽 2010.12.07 110
197 [Applet] Java Plug-in 1.4.2 Developer Guide 황제낙엽 2010.12.07 54
196 [Applet] Java Plugin 가이드 (OBJECT/EMBED 태그에 의한 인트라넷) 황제낙엽 2010.11.06 176
195 [Applet] Java Plugin 가이드 (HTML 컨버터를 사용한 Java Plug-in 용 Applet 태그의 변환) 황제낙엽 2010.11.06 31
194 [Applet] Java Plugin 가이드 (applet,object, 및 embed 태그의 사용) 황제낙엽 2010.11.06 174
193 [Applet] Java Plugin 가이드 (Java Plug-in 란. 지원 내용에 대해) 황제낙엽 2010.11.06 76
» Escape special characters 황제낙엽 2010.10.28 118