I need to convert a Unicode file to ASCII; I found a simple VBScript to do this (see below).
However, I only want to make this conversion if the source file is Unicode. How can I test the file to see if it's Unicode?
Thanks. Here's the script:
However, I only want to make this conversion if the source file is Unicode. How can I test the file to see if it's Unicode?
Thanks. Here's the script:
Code:
Option Explicit
Dim sSourceFileName 'as String
Dim sTargetFileName 'as String
Dim sText 'as String
Dim oFSO 'as Object = Scripting.FileSystemObject
Dim oFile 'as Object = File
sSourceFileName = "C:\UnicodeFile.txt"
sTargetFileName = "C:\ASCIIFile.txt"
Set oFSO = CreateObject("Scripting.FileSystemObject")
'OpenTextFile(source, forreading, createnew, open as Unicode)
Set oFile = oFSO.OpenTextFile(sSourceFileName, 1, , True)
sText = oFile.ReadAll
oFile.Close
'OpenTextFile(destination, forwriting, createnew, open as Ascii)
Set oFile = oFSO.OpenTextFile(sTargetFileName, 2, True, False)
oFile.Write sText
oFile.Close
Set oFile = Nothing
Set oFSO = Nothing