您的位置:程序门 -> vb -> 网络编程



如何提交中文帐户名称到asp论坛


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


如何提交中文帐户名称到asp论坛
发表于:2008-01-18 01:31:01 楼主
用webbrowser控件的post方法提交数据到asp论坛
将中文字符打包成byte时会溢出,怎么办?
如,
ch="靓"   asc(ch)=-2394,而bytearray()   定义为byte,(0-256)
为什么一定要把字符打包成byte才可以上传到asp程序上面呢?
vb.net code
通用模块: private sub packbytes(bytearray() as byte, byval postdata as string) inewbytes = len(postdata) - 1 if inewbytes < 0 then exit sub redim bytearray(inewbytes) for i = 0 to inewbytes ch = mid(postdata, i + 1, 1) if ch = space1) then ch = "+" end if bytearray(i) = asc(ch) next end sub

private   sub   cmd6_click()
            redim   abyte(0)   as   byte

            cpostdata   =   ndata
            packbytes   abyte(),   cpostdata

            for   i   =   lbound(abyte)   to   ubound(abyte)
                    edtpostdata   =   edtpostdata   +   chr(abyte(i))
            next

            dim   vpost   as   variant
            vpost   =   abyte
            dim   vflags   as   variant
            dim   vtarget   as   variant
            dim   vheaders   as   variant
            'vheaders   =   "content-type:   application/x-www-form-urlencoded"   +   chr(10)   +   chr(13)
            vheaders   =   "content-type   content=text/html;   charset=gb2312"
            webbrowser1.navigate   acturl,   vflags,   vtarget,   vpost,   vheaders
end   sub

发表于:2008-01-18 08:28:471楼 得分:0
学习,呼唤高手解答!


快速检索

最新资讯
热门点击