System.Text.UTF8Encoding从VBScript [英] System.Text.UTF8Encoding From VBScript
本文介绍了System.Text.UTF8Encoding从VBScript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您如何从VBScript中调用GetBytes(System.Text.UTF8Encoding)?
How would do you call GetBytes (of System.Text.UTF8Encoding) from VBScript?
您可以使用来自VBScript的.NET Framework 作为它暴露于COM ,但我没有遇到好的文档/手册。
You can use the .NET Framework from VBScript as its exposed to COM, but I haven't come across good documentation/manuals.
推荐答案
如果您在VBScript中寻找等效项,可以使用Ado Stream:
If you are looking for equivalent in VBScript, you can do it using Ado Stream :
Const adTypeBinary = 1
Dim adoStr, bytesthroughado
Set adoStr = CreateObject("Adodb.Stream")
adoStr.Charset = "utf-8"
adoStr.Open
adoStr.WriteText "你好Ğ"
adoStr.Position = 0 'reset position
adoStr.Type = adTypeBinary
adoStr.Position = 3 'skip bom
bytesthroughado = adoStr.Read 'get bytes
WScript.Echo LenB(bytesthroughado) 'length
adoStr.Close
Set adoStr = Nothing
可以从VBScript访问一些.Net组件(来自mscorlib)。
It's possible to access some .Net components (from mscorlib) from VBScript.
Dim encoding, bytesthroughdotnet
Set encoding = CreateObject("System.Text.UTF8Encoding")
bytesthroughdotnet = encoding.GetBytes_4("你好Ğ") 'get bytes
WScript.Echo LenB(bytesthroughdotnet) 'length
Set encoding = Nothing
这篇关于System.Text.UTF8Encoding从VBScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文