"R.Wieser" <***@not.available> wrote
| And I'm not even sure if I want to /install/ PowerShell for this one-off
| action ...
Microsoft have pushed it for years now. So far I have
yet to find something I need it for. You'd like it. It's all
command line applets, like DOS, meant to lure Linux
server managers to Windows. Though I think th fan base
is mostly IT people -- corporate admins who can pass
around specialized scripts.
| > You can use VBScript's ASCII mode (text) stream to
| > do binary file reading/editing.
| Are you sure ? Some time ago I tried to use the ReadAll method (trying
| read a double-byte character textfile so I could convert it into ASCII),
| got rather puzzeled by the returned contents. It turned out that
| the method returned a string the size of the file, it only filled it
| partially (IIRC it stopped on encountering a certain character) which left
| the remainder with whatever was in memory at that time (it didn't even
| the buffer out!).
It stops at nulls. Here's the solution:
Things to know: ReadAll stops at the first null, assuming
it's an end-of-file marker. Textstream is intended to only
be used for text. The WSH planners assumed scripters
wouldn't need or know about binary. So the results are pre-
digested. An ANSI string is interpreted according to the
local codepage. (I dont' know why they call it ASCII. It's
The class above provides workarounds. It will work on
any computer with a non-Asian codepage. (Japan, China
and Korea use a system that doesn't have a character-to-
byte correspondence.) The class can read unicode and leave
in the nulls, as asterisks, or not. It can also handle binary
data. For English, every second byte is a null and every first
byte is the ASCII character, up to 127, so in English the
unicode format is superfluous.
There's also the other option. Is it ADODB.Stream? I'm
not sure. I've rarely used it so I'm not really familiar with
the methods or the Windows version support.