传递字节 (VB.NET)
我需要将编码字符串传递到 php 页面。
要将字符串转换为 iso:
Dim result As Byte() = Encoding.Convert(Encoding.UTF8, Encoding.GetEncoding("iso-8859-1"), input)
我有这段代码来传递字符串,但是我必须如何传递字节(变量结果)而不是字符串(变量 MyVarString)?
Dim client As WebClient
Dim data As Stream
Dim reader As StreamReader
Dim baseurl As String
baseurl = "http://example.com/api/mypage2.php"
client = New WebClient
client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)")
client.QueryString.Add("mensaje", MyVarString)
data = client.OpenRead(baseurl)
reader = New StreamReader(data)
s = reader.ReadToEnd()
data.Close()
reader.Close()
Etc.
I need to pass encoded string to php page.
To convert string to iso:
Dim result As Byte() = Encoding.Convert(Encoding.UTF8, Encoding.GetEncoding("iso-8859-1"), input)
I have this code to pass string, but how I must do it to pass Byte (variable result) instead of the string (variable MyVarString)?
Dim client As WebClient
Dim data As Stream
Dim reader As StreamReader
Dim baseurl As String
baseurl = "http://example.com/api/mypage2.php"
client = New WebClient
client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)")
client.QueryString.Add("mensaje", MyVarString)
data = client.OpenRead(baseurl)
reader = New StreamReader(data)
s = reader.ReadToEnd()
data.Close()
reader.Close()
Etc.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您的问题是如何传递字节数组,那么只需对其进行 Base64 编码:
然后在 PHP 中使用 内置解码器
base64_decode(string)
If your question is how to pass a byte array then just Base64 encode it:
Then in PHP use the built-in decoder
base64_decode(string)