I copied some vbscript code from here: https://www.mjtnet.com/blog/2015/11/11/ ... e-to-utf8/
Then I modified it a little bit so that I could look at the hex and characters in each line, but I don't know if it works yet, I'm getting stuck on a syntax error in the Mid command.
Microsoft says the syntax is right,
https://msdn.microsoft.com/en-us/library/wffts6k3.aspx
I'm thinking empty string. Also, any help in whatever else might be wrong with this script is much appreciated.
Code: Select all
VBSTART
Sub UTFConvert(filename)
Const adTypeBinary = 1
Dim txt
Dim byteValue
Dim line_ra
Dim line
Dim str_Value
Dim str_length
Dim char_ctr
Dim i, j
Set fso = CreateObject("Scripting.FileSystemObject")
txt = fso.OpenTextFile(filename, 1, False, -1).ReadAll
Set stream = CreateObject("ADODB.Stream")
stream.Open
stream.Type = 2 'text
stream.Position = 0
stream.Charset = "utf-8"
'split into lines
line_ra = Split(txt, vbCrLf)
j = 0
For each line in line_ra
i = 0
j = j + 1
'read each byte
str_length = Len(line)
For char_ctr = 1 to str_length
str_Value = Mid(line,i,1)
byteValue = Hex(AscB(str_Value))
MsgBox Cstr(i) & " S:" & str_Value & " H:" & CStr(byteValue)
i = i+1
Next
if j=10 then Exit For
Next
stream.WriteText txt
stream.SaveToFile filename, 2
stream.Close
'byteValue = Right(00 & Hex(AscB(.Read(1))), 2) ' Returns 0A
'WSCript.echo "Value = " & byteValue
End Sub
VBEND
VBRun>UTFConvert,D:\__IBM\_BPS\FDS\fix.fds
MessageModal>Done