게시판 본문 ASP, ASP.NET, IIS & Script - Read Only

re: 죄송합니다.UrlDecode 질문입니다.
작성자: 김지헌
작성일시: 2003-11-08 02:05,  조회수: 1,804
답변 무지무지 감사합니다.
그냥 제가 작업한 부분 적습니다.
php에서 하면...
function crossUrlDecode($source) {
$decodedStr = '';
$pos = 0;
$len = strlen($source);

while ($pos < $len) {
$charAt = substr ($source, $pos, 1);
if ($charAt == 'c') {
$char2 = substr($source, $pos, 2);
$decodedStr .= htmlentities(utf8_decode($char2),ENT_QUOTES,'ISO-8859-1');
$pos += 2;
}
elseif(ord($charAt) > 127) {
$decodedStr .= "&#".ord($charAt).";";
$pos++;
}
elseif($charAt == '%') {
$pos++;
$hex2 = substr($source, $pos, 2);
$dechex = chr(hexdec($hex2));
if($dechex == 'c') {
$pos += 2;
if(substr($source, $pos, 1) == '%') {
$pos++;
$char2a = chr(hexdec(substr($source, $pos, 2)));
$decodedStr .= htmlentities(utf8_decode($dechex . $char2a),ENT_QUOTES,'ISO-8859-1');
}
else {
$decodedStr .= htmlentities(utf8_decode($dechex));
}
}
else {
$decodedStr .= $dechex;
}
$pos += 2;
}
else {
$decodedStr .= $charAt;
$pos++;
}
}

return $decodedStr;
}

이렇게 하면 되던데요..


그래서 ASP 코드로

Function hexdec(strHex)
For i = 0 To Len(strHex) - 1
lngDec = lngDec + CInt("&H" & Mid(strHex, Len(strHex) - i, 1)) * 16 ^ i
Next
hexdec = lngDec
End Function

function crossUrlDecode(source)
decodedStr = ""
pos = 1
str_len = Len(source)

Do While pos <= Len(source)
charAt = Mid (source, pos, 1)
If charAt = "c" Then
char2 = Mid(source, pos, 2)
decodedStr = decodedStr & char2
pos = pos + 2

ElseIf asc(charAt) > 127 Then
decodedStr = decodedStr & "&#" & asc(charAt) & ""
pos = pos + 1

ElseIf charAt = "%" Then
pos = pos + 1
hex2 = Mid(source, pos, 2)
dechex = chr(hexdec(hex2))
If dechex = "c" Then
pos = pos + 2
If Mid(source, pos, 1) = "%" Then
pos = pos + 1
char2a = chr(hexdec(Mid(source, pos, 2)))
decodedStr = decodedStr & dechex & char2a
Else
decodedStr = decodedStr & dechex
End If
Else
decodedStr = decodedStr & dechex
End If
pos = pos + 2
Else
decodedStr = decodedStr & charAt
pos = pos + 1
End If
Loop

crossUrlDecode = decodedStr

End Function

이렇게 바꿨습니다.

그런데... 한글이 인코딩된 부분은 무조건 안나오네요.

utf8_decode()는 구현은 실력이 모자라 못하고... 인터넷서 찾는 중입니다.

IP 주소: 211.238.157.11
전체 2,095 건의 게시물, 84 페이지로 구성된 ASP, ASP.NET, IIS & Script 게시판의 80 페이지입니다.
게시물
133

re: my-sql 날짜를 ms-sql로 가지고 왔는데...

송원석

2003-11-14 5,278
132

안녕하세요 송군님 또 질문이에요^^

asper

2003-11-08 916
131

re: 안녕하세요 송군님 또 질문이에요^^

송원석

2003-11-08 2,750
130

죄송합니다.UrlDecode 질문입니다.

김지헌

2003-11-07 2,929
129

re: 죄송합니다.UrlDecode 질문입니다.

송원석

2003-11-07 3,058

re: 죄송합니다.UrlDecode 질문입니다.

김지헌

2003-11-08 1,804
127

re: 죄송합니다.UrlDecode 질문입니다.

송원석

2003-11-08 2,904
126

안녕하세요 질문이 하나있어어요

asper

2003-11-07 802
125

re: 안녕하세요 질문이 하나있어어요

cipas

2003-11-07 2,722
124

re: 안녕하세요 질문이 하나있어어요

송원석

2003-11-07 2,877
123

re: 안녕하세요 질문이 하나있어어요

asper

2003-11-07 824
122

re: 죄송하지만 다시질문을 ^^

asper

2003-11-07 772
121

re: 죄송하지만 다시질문을 ^^ [1]

송원석

2003-11-07 2,858
120

영문판에서...

cipas

2003-11-04 2,764
119

re: 영문판에서...

송원석

2003-11-04 2,766
118

파일큐브 버그..

cipas

2003-11-02 2,957
117

re: 허거덕... 그렇군요. 그런데 조금 이상한 점이... ^_^;;;

송원석

2003-11-03 2,897
116

re: 허거덕... 그렇군요. 그런데 조금 이상한 점이... ^_^;;;

cipas

2003-11-03 2,822
115

re: 허거덕... 그렇군요. 그런데 조금 이상한 점이... ^_^;;;

송원석

2003-11-03 3,049
114

보안 싸이트로 포워딩에 관해서....

cipas

2003-10-26 3,151
113

re: 보안 싸이트로 포워딩에 관해서....

송원석

2003-10-26 2,833
112

re: 보안 싸이트로 포워딩에 관해서....

cipas

2003-10-26 2,946
111

re: 요즘 많이 바쁘신가봐요?

cipas

2003-10-30 2,787
110

re: 요즘 많이 바쁘신가봐요?

송원석

2003-10-30 3,059
109

re: 반은 해결... ^^

cipas

2003-10-30 2,924