"Billy Smith" <> writes:
> I'm trying to write a little utility that will write some
> binary data to a file via a javascript and Windows Script Host
> under Windows XP. The only way to do this that I can find
> is to convert the binary data to text via String.fromCharCode()
> function and then write to the file with TextStream.Write().
>
> But that function gives an "invalid parameter" error message
> when I try to write some ASCII codes to the file. I could
> understand if it refused to write any of the extended ASCII
> characters but it accepts some and not others. For example
> it will write characters with codes 157, 255, and 188 but
> fails on 156 and 128, both of which are printable characters.
Neither 128 nor 156 are ASCII characters, nor are they defined in
ISO-8859-1. In Unicode, those code points are control characters
(128 is apparently an undefined control character, and 156 is
"single character introducer").
Apparently textual output of these code points fails.
You should also be aware that code point 128 is not represented
as one byte using UTF-8 encoding (or any other standardized
encoding of Unicode), so even if it can be written, it won't give
you what you want.
> It works with ordinary characters (codes 0-127) just fine.
As it should, these are Unicode characters as well.
> 2) It's beginning to look to me like javascript and WSH don't
> provide a way to write binary data. Am I right or is there
> a way to write binary data to a file using these tools?
There is nothing in Javascript itself. I don't know the capabilities
of WSH. But a Google on "wsh write binary file" seems useful.
/L
--
Lasse Reichstein Nielsen -
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'