2012-03-17 3 views

답변

3

당신이 VBScript로 상당을 찾고 있다면, 당신은 아도 스트림을 사용하여 수행 할 수 있습니다

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 (mscorlib에에서) 일부 닷넷 구성 요소에 액세스 할 수 있습니다.

Dim encoding, bytesthroughdotnet 
Set encoding = CreateObject("System.Text.UTF8Encoding") 
    bytesthroughdotnet = encoding.GetBytes_4("你好Ğ") 'get bytes 
    WScript.Echo LenB(bytesthroughdotnet) 'length 
Set encoding = Nothing 
+0

GetBytes_4에서 "_4"를 사용하는 것을 어떻게 알고 있습니까? – Eugene

+1

@ user389823 적절한 방법을 찾을 때까지 접미어를 늘립니다. 불행히도 접미사의 순서는 .Net 오버로드 목록과 일치하지 않습니다. 누군가가 정말로 알고 있는지 듣고 싶습니다. –

+0

http://stackoverflow.com/questions/9755263/determining-net-method-suffix-number-in-vbscript-com에서 질문을했습니다. 다시 한 번 감사드립니다. (원래는 _3까지만 올라갔습니다)! – Eugene