Andrew Aronoff
2005-06-15 21:23:52 UTC
I'm using VBS to open a text file that may be ASCII or Unicode. I
don't know in advance the format of the file. I need to compare the
file, line by line, with an ASCII equivalent stored in the script. If
differences are found in any line, I want to output to a text file the
ASCII version of the line in the text file. Unicode characters without
ASCII equivalents can be represented as a question mark. There will be
very very few such characters in the Unicode version of the text file.
Here's my simple code to open the text file for reading:
Const ForReading = 1
Const TriStateFalse = 0, TriStateTrue = -1, TriStateUseDefault = -2
Set oTextFile = Fso.OpenTextFile (strFileName, ForReading, _
False,TriState_value_here)
If I use TriStateUseDefault, both ASCII and Unicode files can be read
and compared to ASCII, with any differences correctly output to a text
file. I don't understand why. How is TriStateUseDefault able to
correctly distinguish between ASCII and Unicode files when the files
are opened with OpenTextFile?
regards, Andy
don't know in advance the format of the file. I need to compare the
file, line by line, with an ASCII equivalent stored in the script. If
differences are found in any line, I want to output to a text file the
ASCII version of the line in the text file. Unicode characters without
ASCII equivalents can be represented as a question mark. There will be
very very few such characters in the Unicode version of the text file.
Here's my simple code to open the text file for reading:
Const ForReading = 1
Const TriStateFalse = 0, TriStateTrue = -1, TriStateUseDefault = -2
Set oTextFile = Fso.OpenTextFile (strFileName, ForReading, _
False,TriState_value_here)
If I use TriStateUseDefault, both ASCII and Unicode files can be read
and compared to ASCII, with any differences correctly output to a text
file. I don't understand why. How is TriStateUseDefault able to
correctly distinguish between ASCII and Unicode files when the files
are opened with OpenTextFile?
regards, Andy
--
**********
Please send e-mail to: usenet (dot) post (at) aaronoff (dot) com
To identify everything that starts up with Windows, download
"Silent Runners.vbs" at www.silentrunners.org
**********
**********
Please send e-mail to: usenet (dot) post (at) aaronoff (dot) com
To identify everything that starts up with Windows, download
"Silent Runners.vbs" at www.silentrunners.org
**********