Microsoft MVP성태의 닷넷 이야기
XMLHTTP 에서 반환받은 non-XML 데이터를 보여주는 모듈 [링크 복사], [링크+제목 복사],
조회: 11053
글쓴 사람
정성태 (techsharer at outlook.com)
홈페이지
첨부 파일
 

뉴스그룹에 올라온 소스입니다.
VB 스크립트로 작성한 Binary -> ASCII 디코딩 소스인데, XMLHTTP 의 반환값을 해석하는 데에 유용하게 쓸 수 있습니다.

보통 XMLHTTP 가 XML 문서가 아닌 반환값에 대해서는 Binary 데이터만을 보여주어서 한글이 깨져 보이게 됩니다. 즉, 한글이 포함된 HTML 문서의 경우에는 아래에서 보여주는 BinDecode VB 함수를 사용하시면 됩니다.

한가지 주의하실 것은, 아무래도 Script 함수이다 보니 조금 긴 HTML 텍스트의 경우에는 과도한 루프와 문자열 연산때문에 CPU 부하가 너무 걸린다는 것이죠. 스크립트로는 극복할 수 없고, 만약 ActiveX 를 배포할 수 있는 상황이라면 VC++ COM 개체로 구현하시는 것도 좋은 방법일 수 있습니다.


<script language="javascript">

function ViewHtmlPage()
{
    var x = new ActiveXObject("Microsoft.XMLHTTP")
    x.open("get","test.asp",false);
    x.send();
    var strv = x.responseBody;
    document.body.innerHTML = BinDecode(strv);
}
</script>

<script language="vbscript">
'-----------------------------------------
' BinDecode (바이너리 -> 아스키 변환)
' mongmong - 2003. 2
'-----------------------------------------
    Public Function BinDecode(byVal binData)
        Dim i, byteChr, strV
        For i = 1 to LenB(binData)
            byteChr = AscB(MidB(binData,i,2))
            If byteChr > 127 Then
                i = i + 1
                strV = strV & Chr("&H" & Hex(byteChr) & Hex(AscB(MidB(binData,i,2))))
            Else
                strV = strV & Chr(byteChr)
            End if
        Next
        BinDecode = strV
    End Function
</script>









[최초 등록일: ]
[최종 수정일: 2/15/2004]


비밀번호

댓글 작성자
 




... 31  32  33  34  35  [36]  37  38  39  40  41  42  43  44  45  ...
NoWriterDateCnt.TitleFile(s)
296정성태5/27/200613205WWF 로 만든 Tetris
294정성태5/21/200613276Session State Uses a Reader-Writer Lock
293정성태5/21/200611929Microsoft Threat Analysis & Modeling v2.0 RC1
291정성태5/18/200613258Managed Stack Explorer
289정성태5/17/200613723Microsoft ASP.NET Providers - PDF 메뉴얼
288정성태5/17/200614095TFS Administration Tool 1.0 Released...with Shared Source!
287정성태5/17/200613172An Introduction to 64-bit Installers with Visual Studio 2005: Part 1
283정성태5/15/200613730Windows Workflow Foundation: Running Service Activated Workflows on Windows Vista and IIS7
284정성태5/15/200613950    답변글 Windows Workflow Foundation: Exposing Workflows as Services [1]
281정성태5/12/200612482Microsoft Compute Cluster Pack SDK
280정성태5/11/200616657C# 3.0 : One-Step Object Creation and Initialization
279정성태5/11/200614554Vista에서 제거되는 DHTML Editing Control
278정성태5/11/200612817LINQ CTP - May 2006
286정성태5/16/200612329    답변글 Using LINQ with ASP.NET (Part 1)
277정성태5/9/200612433Web Application Projects - 정식 릴리스
276정성태5/8/200612778SNK 파일 공유하기파일 다운로드1
275정성태5/8/200612513Building Security Awareness in .NET Assemblies
274정성태5/7/200612460QuickSYS파일 다운로드2
273정성태5/7/200612703Developing Firewalls for Windows 2000/XP파일 다운로드1
272정성태5/6/200614665Windows PowerShell [3]
292정성태5/19/200612808    답변글 Windows PowerShell - PowerShell Script to Create a WorkItem
271정성태5/6/200613054MSBee
282정성태5/15/200612895    답변글 MSBee will be on CodePlex
290정성태5/18/200613343    답변글 MSBuild Extras - Toolkit for .NET 1.1 "MSBee"
270정성태5/4/200613094ISO Recorder
269정성태5/4/200613051Visual Studio 2005 Team System Level 200 Course Material
... 31  32  33  34  35  [36]  37  38  39  40  41  42  43  44  45  ...