Post
KO

asp jQuery ajax serialize 사용시 한글 깨짐 처리

스크립트로 쓸까 말까asp 하다가 적는다. [펌]

출처 : http://koong.net/index.php?MenuID=4&mode=view&idx=874&list_count=100&cat=

————- 2013.05.24 —————-

와놔 파라미터 깨지는 현상 발생

1*2 3 4     var datas =$(“#”+formName).serialize().replace(/=(.[^&])/g,              function($0,$1){                  return ”=”+escape(decodeURIComponent($1))             });

수정함 ㅋ 이것때문에 야근함 짜증

———— 2013.05.27 —————–

위 방법대로 하다보면 주소값 = 전달 하는 input text 폼에 값이 null 일때 %로 변경된다.

따라서 다른 방법으로 해당 폼안에 값들을 모두 가져와서 셋팅해주는 방법으로 했다.

물론 한글 깨지는 현상은 escape(decodeURIComponent를써서 디코딩해주었고

asp 페이지 단으로가서

다시 아래 함수를 이용해서 디코딩 해줬더니 한글 깨짐 문제는 해결 되었다.

왜 한글 깨지는지는 나도 모르겠음..

Function URLDecode(sConvert)     Dim aSplit     Dim sOutput     Dim I     If IsNull(sConvert) Then        URLDecode = ””        Exit Function     End If

    ’ convert all pluses to spaces     sOutput = REPLACE(sConvert, ”+”, ” ”)

    ’ next convert %hexdigits to the character     aSplit = Split(sOutput, ”%”)

    If IsArray(aSplit) Then       sOutput = aSplit(0)       For I = 0 to UBound(aSplit) - 1         sOutput = sOutput & _           Chr(“&H” & Left(aSplit(i + 1), 2)) &_           Right(aSplit(i + 1), Len(aSplit(i + 1)) - 2)       Next     End If

    URLDecode = sOutput End Function

This article is licensed under CC BY 4.0 by the author.