| 发表于: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 = space(1) 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 |
|
|
|
|