Determine if a file is Unicode or ANSI
I have a bunch of INF files that I'm trying to work with. The problem I'm finding is that some of them are Unicode format and some are ANSI.
I can open and read in the file fine, but when I try to write out to it, my script crashes.
VB Code:
Set outFile = FS.GetFile(FSFile.Path).OpenAsTextStream(2, -2) 'save INF in ANSI format to save space
outFile.Writeline FileString 'write the modified text
outFile.Close 'close file handle
set OutFile = Nothing
If I write a null value to the file it seems to work fine.
Re: Determine if a file is Unicode or ANSI
I also found out that it is crashing due to invalid characters. The Unicode format supports a larger character set than ANSI. The INF file I have contains Chinese characters which are causing the script to choke when it tries to write them out to the ANSI file.
Now, the question is... is there a way to convert these Unicode characters, without going through each and every character in the string and testing it? Ugh... there must be an easier way.
Re: Determine if a file is Unicode or ANSI
Heck I'll even settle for a batch file if it gets the job done.