글 작성자: 써니루루

만약에 '사랑해' 라는 문자열을 입력하면 '%uC0AC%uB791%uD574' 라는 유니코드로 escape해주는 자바스크립트이다 ^ ^




<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Escape / Unescape</title>

    <script type="text/javascript">
    <!--//
    function enCode()
    {
        var temp = escape(document.forms[0].inV.value);

        document.forms[0].outV.value = temp;
    }

    function deCode()
    {
        var temp = unescape(document.forms[0].inV.value);

        document.forms[0].outV.value = temp;
    }
    //-->
    </script>

</head>
<body>
    <form name="fo" action="">
    <input type="text" name="inV" /><br />
    <input type="button" value="인코딩" onclick="enCode()" />
    <input type="button" value="디코딩" onclick="deCode()" /><br />
    <input type="text" value="" name="outV" />
    </form>
</body>
</html>