utf-8 을 ecu-kr
스크립트 이용이것은 utf-8을 자바스크립트로 escape 시켜서 <%@LANGUAGE="VBSCRIPT" CODEPAGE="949"%><% Response.CharSet = "euc-kr" %> <%bb = unescape(Request("bb")) sample = Request("sample") sample1 = unescape(Request("sample1")) Response.Write bb & "<br>"Response.Write sample & "<br>"Response.Write sample1 & "<br>"%><% @LANGUAGE='VBSCRIPT' CODEPAGE='65001' %><% Response.CharSet = "utf-8" %><script>function checkForm(f){ f.sample1.value = escape(f.sample.value);}</script><form Method="POST" name="user" action="kor8.asp" onsubmit="return checkForm(this)"><input type="hidden" name="bb" value="<%=escape("가나다라마바사")%>"> <input type="image" src="zzzzzzz.jpg"><input type="hidden" name="sample1" id="textfield" /><input type="text" name="sample" id="textfield" /></form>
함수1
Function DecodeUTF8 (s)
Dim i
Dim c
Dim n
i = 1
Do While i <= Len(s)
c = Asc(Mid(s, i, 1))
If c And &H80 Then
n = 1
Do While i + n < Len(s)
If (Asc(Mid(s, i+n, 1)) And &HC0) <> &H80 Then
Exit Do
End If
n = n + 1
Loop
If n = 1 And ((c And &HE0) = &HC0) Then
c = Asc(Mid(s, i+1, 1)) + &H40 * (c And &H01)
Else
c = 191
End If
s = Left(s, i-1) + Chr(c) + Mid(s, i+n)
End If
i = i+1
Loop
DecodeUTF8 = s
End Function
함수 2
Public Function DecodeUTF8(byVal pURL)
Dim i, s1, s2, s3, u1, u2, result
pURL = Replace(pURL,"+"," ")
For i = 1 to Len(pURL)
if Mid(pURL, i, 1) = "%" then
s1 = CLng("&H" & Mid(pURL, i + 1, 2))
'2바이트일 경우
if ((s1 AND &HC0) = &HC0) AND ((s1 AND &HE0) <> &HE0) then
s2 = CLng("&H" & Mid(pURL, i + 4, 2))
u1 = (s1 AND &H1C) / &H04
u2 = ((s1 AND &H03) * &H04 + ((s2 AND &H30) / &H10)) * &H10
u2 = u2 + (s2 AND &H0F)
result = result & ChrW((u1 * &H100) + u2)
i = i + 5
'3바이트일 경우
elseif (s1 AND &HE0 = &HE0) then
s2 = CLng("&H" & Mid(pURL, i + 4, 2))
s3 = CLng("&H" & Mid(pURL, i + 7, 2))
u1 = ((s1 AND &H0F) * &H10)
u1 = u1 + ((s2 AND &H3C) / &H04)
u2 = ((s2 AND &H03) * &H04 + (s3 AND &H30) / &H10) * &H10
u2 = u2 + (s3 AND &H0F)
result = result & ChrW((u1 * &H100) + u2)
i = i + 8
end if
else
result = result & Mid(pURL, i, 1)
end if
Next
DecodeUTF8 = result
End Function
* 위 함수 두개다 정상적으로 변환되는지의 여부가 불확실하다..ㅡ.ㅡ;
euc-kr 을 utf-8로이것은 걍 함수를 사용Public Function toUTF8(szSource As String) As String On Error GoTo ErrHandler Dim szChar As String Dim WideChar As Long Dim nLength As Integer Dim i As Integer nLength = Len(szSource) For i = 1 To nLength szChar = Mid(szSource, i, 1) If Asc(szChar) < 0 Then WideChar = CLng(AscB(MidB(szChar, 2, 1))) * 256 + AscB(MidB(szChar, 1, 1)) If (WideChar And &HFF80) = 0 Then toUTF8 = toUTF8 & "%" & Hex(WideChar) ElseIf (WideChar And &HF000) = 0 Then toUTF8 = toUTF8 & _ "%" & Hex(CInt((WideChar And &HFFC0) / 64) Or &HC0) & _ "%" & Hex(WideChar And &H3F Or &H80) Else toUTF8 = toUTF8 & _ "%" & Hex(CInt((WideChar And &HF000) / 4096) Or &HE0) & _ "%" & Hex(CInt((WideChar And &HFFC0) / 64) And &H3F Or &H80) & _ "%" & Hex(WideChar And &H3F Or &H80) End If Else toUTF8 = toUTF8 + szChar End If Next Exit Function ErrHandler: toUTF8 = ""End Functionutf8.asp<% @LANGUAGE='VBSCRIPT' CODEPAGE='65001' %><% Response.CharSet = "utf-8" %><form Method="POST" name="user" action="kor8.asp"><input type="hidden" name="bb" value="<%=escape("가나다라마바사")%>"> <input type="image" src="zzzzzzz.jpg"></form>kor8.asp<%@LANGUAGE="VBSCRIPT" CODEPAGE="949"%><% Response.CharSet = "euc-kr" %> <%bb = unescape(Request("bb")) Response.Write bb & "<br>"%>