YesYo.com MintState Forums
뒤로    YesYo.com MintState BBS > Tech > Javascript
검색
멤버이름    오토
비밀번호 
 

escape() 함수와 unescape() 함수

페이지 정보

작성자 MintState 댓글 0건 조회 16,128회 작성일 09-01-05 12:14

본문

escape() 함수와 unescape() 함수

escape() 함수는 알파벳과 숫자 및 * , @, - , _ , + , . , / 를 제외한 문자를 모두 16진수 문자로 바꾸어 줍니다. 이 함수는 쉼표와 세미콜론 같은 문자가 쿠키문자열과의 충돌을 피하기 위해 사용됩니다.

이렇게 16진수 문자열로 변환된 문자열은 unescape() 함수로 다시 되돌려줄 수 있습니다


<SCRIPT LANGUAGE="JavaScript"> 
<!-- 
document.write("escape('우리나라') ===>" + escape('우리나라') + "<br>"); 
document.write("escape('korea') ===>" + escape('korea') + "<br>"); 
document.write("escape('#$%^') ===>" + escape('#$%^') + "<br>"); 
document.write("escape('1234') ===>" + escape('1234') + "<br>"); 
document.write("escape('*@-_+./') ===>" + escape('*@-_+./') + "<br><br>"); 
document.write("unescape('%uC6B0%uB9AC%uB098%uB77C') ===>" + unescape('%uC6B0%uB9AC%uB098%uB77C') + "<br>"); 
document.write("unescape('%23%24%25%5E') ===>" + unescape('%23%24%25%5E') + "<br>"); 
//--> 
</SCRIPT>


예제에서 보듯이 영어 알파벳과 숫자, 그리고 *@-_+./를 제외한 문자는 모두 escape() 함수를 이용하면 16진수 문자열로 변환될 수 있고, 변환된 문자열을 unescape() 함수를 이용해 다시 원상태로 복구 시킬 수 있습니다
----------------------------------------------


맨위에 <script language="javascript">document.write(unescape("\x3C ....에서 unescape의 un을 빼고 escape 로 만든다.

html형식으로 파일을 저장시키고 다시 열어보면 (%3Cbody%20oncontextmenu%3D%22return%20false%22%20onselectstart%3D%22return%....생략 ) 식으로 뜸

나타난 소스를 복사, 그리고 다음 사이에 붙여넣기하기  unescape(" 여기 ")

 <script language="javascript">document.write(unescape("(%3Cbody%20oncontextmenu%3D%22return%20false%22%20onselectstart%3D%22return%....중간 생략")

unescape(" 다음에 %3Cxmp%3E 소스를 붙여넣기

(unescape("(%3Cxmp%3E %3Cbody%20oncontextmenu%3D%22return%20false%22%20onselectstart%3D%22return%....중간 생략")


html파일로 출력하면  풀린 소스가 나타남.

댓글목록

등록된 댓글이 없습니다.

Total 178건 2 페이지
게시물 검색
모바일 버전으로 보기
CopyRight ©2004 - 2024, YesYo.com MintState. ™