Board logo

标题: [技术讨论] VBS如何把string转换成byte()? [打印本页]

作者: jyswjjgdwtdtj    时间: 2023-6-16 19:20     标题: VBS如何把string转换成byte()?

网上的方法 来自demon.tw 大佬的代码么 就是抄来抄去
  1. 'Author: Demon
  2. 'Website: http://demon.tw
  3. 'Date: 2012/2/22
  4. Dim xmldoc, node, bytes
  5. Set xmldoc = CreateObject("Msxml2.DOMDocument")
  6. Set node = xmldoc.CreateElement("binary")
  7. node.DataType = "bin.hex"
  8. 'demon.tw 的十六进制值为
  9. '64 65 6D 6F 6E 2E 74 77
  10. node.Text = "64656D6F6E2E7477"
  11. bytes = node.NodeTypedValue
  12. WScript.Echo VarType(bytes), TypeName(bytes)
复制代码
有些离谱的是如果用以上代码WScript.Echo bytes 会输出一堆乱码
完全有更简单的方法
  1. set v=createobject("wia.vector")
  2. v.setfromstring("balabala")
  3. msgbox typename(v.binarydata)
复制代码

作者: 老刘1号    时间: 2023-6-17 18:23

MidB和AscB路过
作者: Five66    时间: 2023-8-1 14:50

可是wia.vector的setfromstring得到的是unicode序列的byte()
作者: jyswjjgdwtdtj    时间: 2023-8-1 15:47

回复 3# Five66


    嗯 第一个是gbk的 所以是乱码




欢迎光临 批处理之家 (http://www.bathome.net/) Powered by Discuz! 7.2