한국어로 보기
This is a simple COM component for the URL encoding. It is based on the CHttpClient. The major reason to write this component is the lack of capability to decode a URL encoded string in ASP. It supports URL encoding and decoding. If you want to use this component, you have to install HyeongryeolUrlEncoder.dll and register it by using the regsvr32.exe program.
(I recommend you to install it in the %WINDOWS%System32 folder.)

You can use this component as the following code in ASP.
Set objEncoder = Server.CreateObject ("Hyeongryeol.UrlEncoder")
objEncoder.CodePage = Response.CodePage

strEncoded = objEncoder.Encode ("Test sample")
strDecoded = objEncoder.Decode (strEncoded)
As you can see in the above code, you can also specify a code page property. It is useful if you have to send a query string to an another site in a different code page. The default code page is CP_ACP.

The following two ASP pages show how to communicate between an UTF-8 site and an ANSI site(korean) through a query string.
<%@ Language="VBScript" CodePage="65001" %>
<%
'
' An unicode site (UTF-8, http://sitea/url.asp)
'
%>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>http://sitea/url.asp</title>
</head>
<body>
    A passed string: <%=Request.QueryString ("passed")%><br />
    <br />

<%
    Set objEncoder = Server.CreateObject ("Hyeongryeol.UrlEncoder")
    objEncoder.CodePage = 949   ' Set the korean code page.
%>

    <a href="http://siteb/url.asp?passed=<%=objEncoder.Encode ("테스트 한국어")%>">
        Go Site B with an URL encoded korean ANSI string.
    </a>
</body>
</html>
<%@ Language="VBScript" CodePage="949" %>
<%
'
' An ANSI site (korean, http://siteb/url.asp)
'
%>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=euc-kr">
    <title>http://siteb/url.asp</title>
</head>
<body>
    A passed string: <%=Request.QueryString ("passed")%><br />
    <br />

<%
    Set objEncoder = Server.CreateObject ("Hyeongryeol.UrlEncoder")
    objEncoder.CodePage = 65001   ' Set the UTF-8 code page.
%>

    <a href="http://sitea/url.asp?passed=<%=objEncoder.Encode ("테스트 한국어")%>">
        Go Site A with an URL encoded UTF-8 unicode string.
    </a>
</body>
</html>
신고

티스토리 툴바