轉碼
語法系統管理
取得命令列參數
轉碼
VBS字串實字
VBS字串的內部實現
直譯器資訊

轉碼主要是利用 stream 物件的 readText 將來源串流轉成字串,再用 writeText 方法將字串寫入目標編碼的位元串流,如下碼:

option explicit

dim txt, src, dst

txt = wscript.arguments(0)

'ADODB.Stream file I/O constants
const adTypeBinary          = 1
const adTypeText            = 2
const adSaveCreateOverWrite = 2
const adReadAll             = -1
const adWriteChar           = 0

with createObject("ADODB.Stream")
    dim strText
    .open
    .type = adTypeBinary
    .loadFromFile txt
    .type = adTypeText
    .charset = "utf-8"
    strText = .readText(adReadAll)
    .position = 0
    .setEOS
    .charset = "big5"
    .writeText strText, adWriteChar
    .saveToFile txt & "_big5.txt", adSaveCreateOverWrite
    .close
end with