-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathconvert utf-8 to ansi.vbs
More file actions
41 lines (33 loc) · 938 Bytes
/
convert utf-8 to ansi.vbs
File metadata and controls
41 lines (33 loc) · 938 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
' Convert UTF-8 file to ANSI
currentdir=Left(WScript.ScriptFullName,InStrRev(WScript.ScriptFullName,"\"))
source = currentdir & "source.txt"
dest = currentdir & "dest.txt"
charset= "Windows-1252"
Set stream=CreateObject("ADODB.Stream")
stream.Open
stream.Type = 1
stream.LoadFromFile source
stream.Type = 2
stream.Charset = "utf-8"
Dim fso
Set fso = CreateObject("Scripting.Filesystemobject")
Set f = fso.CreateTextFile(dest, True)
Do Until stream.EOS
strLine = stream.ReadText(10000)
Set output=CreateObject("ADODB.Stream")
output.Open
output.Type = 2
output.Charset = charset
output.WriteText strLine
output.Position = 0
str = output.ReadText(-1)
f.Write str
Loop
f.Close
stream.Close