復(fù)制代碼 代碼如下:
'/*=========================================================================
' * Intro 拖動所有要轉(zhuǎn)換的gb2312編碼文件到這個文件上,程序會將它們自動轉(zhuǎn)換為utf-8編碼文件
' * FileName GB2312.To.UTF-8.vbs
' * Author yongfa365
' * Version v1.0
' * WEB http://www.yongfa365.com
' * Email yongfa365[at]qq.com
' * LastModify 2007-10-04 10:42:53
' *==========================================================================*/
Set objArgs = WScript.Arguments
If objArgs.Count>0 Then
If MsgBox("本程序僅支持GB2312到UTF-8的轉(zhuǎn)換"vbCrLf"如果您所拖動的文件里有別的格式的文件請點“取消”", vbOKCancel + vbExclamation + vbDefaultButton2, "鄭重提醒!!!") = vbOK Then
For I = 0 To objArgs.Count - 1
FileUrl = objArgs(I)
Call WriteToFile(FileUrl, ReadFile(FileUrl, "gb2312"), "utf-8")
Next
End If
Else
MsgBox "請將您要轉(zhuǎn)換的“gb2312文件”拖到這個文件上"vbCrLf"程序會將它們自動轉(zhuǎn)換為utf-8文件", vbInformation, "柳永法溫馨提示:"
End If
'-------------------------------------------------
'函數(shù)名稱:ReadFile
'作用:利用AdoDb.Stream對象來讀取各種格式的文本文件
'----------------------------------------------------
Function ReadFile(FileUrl, CharSet)
Dim Str
Set stm = CreateObject("Adodb.Stream")
stm.Type = 2
stm.mode = 3
stm.charset = CharSet
stm.Open
stm.loadfromfile FileUrl
Str = stm.readtext
stm.Close
Set stm = Nothing
ReadFile = Str
End Function
'-------------------------------------------------
'函數(shù)名稱:WriteToFile
'作用:利用AdoDb.Stream對象來寫入各種格式的文本文件
'參數(shù):FileUrl-文件相對路徑;Str-文件內(nèi)容;CharSet-編碼格式(utf-8,gb2312.....)
'----------------------------------------------------
Function WriteToFile (FileUrl, Str, CharSet)
Set stm = CreateObject("Adodb.Stream")
stm.Type = 2
stm.mode = 3
stm.charset = CharSet
stm.Open
stm.WriteText Str
stm.SaveToFile FileUrl, 2
stm.flush
stm.Close
Set stm = Nothing
End Function
您可能感興趣的文章:- 將字符串轉(zhuǎn)換成gb2312或者utf-8編碼的參數(shù)(js版)
- php實現(xiàn)utf-8和GB2312編碼相互轉(zhuǎn)換函數(shù)代碼
- UTF-8 GBK UTF8 GB2312 之間的區(qū)別和關(guān)系介紹
- PHP字符編碼問題之GB2312 VS UTF-8解決方法
- VBS實現(xiàn)GB2312,UTF-8,Unicode,BIG5編碼轉(zhuǎn)換工具
- PHP 解決utf-8和gb2312編碼轉(zhuǎn)換問題
- unicode utf-8 gb18030 gb2312 gbk各種編碼對比
- ASP中Utf-8與Gb2312編碼轉(zhuǎn)換亂碼問題的解決方法 頁面編碼聲明
- MSSQL轉(zhuǎn)MYSQL,gb2312轉(zhuǎn)utf-8無亂碼解決方法
- PHP iconv 解決utf-8和gb2312編碼轉(zhuǎn)換問題
- ASP UTF-8頁面亂碼+GB2312轉(zhuǎn)UTF-8 +生成UTF-8格式的文件(編碼)
- 用javascript實現(xiàn)gb2312轉(zhuǎn)utf-8的腳本
- [轉(zhuǎn)]ASP實現(xiàn)關(guān)鍵詞獲取(各搜索引擎,GB2312及UTF-8)
- UTF-8轉(zhuǎn)GB2312函數(shù)
- utf-8編碼轉(zhuǎn)換成gb2312
- 將編碼從GB2312轉(zhuǎn)成UTF-8的方法匯總(從前臺、程序、數(shù)據(jù)庫)