Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Saving strings to binary file. ADODB

3 views
Skip to first unread message

Thomas

unread,
Jan 7, 2002, 2:11:48 AM1/7/02
to
I am struggling to find a way to get a string respresenting binary data in
JScript down to a binary file
with 100% no success. I was certain this could be achieved with
ADODB.Stream/RecordSet,
but after 5 hrs I am beginning to doubt it's doable at all.

I had an idea you could convert a string to a body8209 type with RecordSet
and
then write it to disk with the Stream object. but the closest I got on that
one was getting
stuck with some weird unicode/ascii mismatches adding a 0x00 char every
other byte on
the written file.

Does anyone have any info/example to achieve this in WSH/Jscript
environment,
especially involving the RecordSet object and how to use it for this special
case of "typecasting".


any help appreciated,
Thomas.


Fred Chateau

unread,
Jan 7, 2002, 2:39:17 AM1/7/02
to
"Thomas" wrote ...

> I had an idea you could convert a string to a body8209 type with RecordSet
and then write it to disk with the Stream object. but the closest I got on
that one was getting stuck with some weird unicode/ascii mismatches adding a
0x00 char every other byte on the written file.

It sounds like it's still be handled as text. I don't know if this will help
but look around for functions that use Tristate parameters and maybe you can
handle the conversion better.

i.e. - Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0

Also, maybe this script utility package might help.

http://www.pstruh.cz/help/ScptUtl/library.htm

Regards,

Fred Chateau

Thomas

unread,
Jan 7, 2002, 1:25:38 PM1/7/02
to
"Fred Chateau" <fcha...@home.com> wrote in message
news:Fgc_7.29703$LQ1.9...@news2.nash1.tn.home.com...

> "Thomas" wrote ...
>>
> > I had an idea you could convert a string to a body8209 type with
RecordSet
>> and then write it to disk with the Stream object. but the closest I got
on
>> that one was getting stuck with some weird unicode/ascii mismatches
adding a
>> 0x00 char every other byte on the written file.
>
> It sounds like it's still be handled as text. I don't know if this will
help
> but look around for functions that use Tristate parameters and maybe you
can
> handle the conversion better.
>
> i.e. - Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse =
0

you mean for ADODB.Stream ??

if you'r talking about FSO I already tried that. I can only get it to save
the chunk
at TristateTrue, in any other case will make FSO throw up an error.
in the resulting file some byte-ranges fails to go unicode ..

it's strange, i've seen examples in VBS using the FSO object to convert and
save
a stream as binary, but tryin the same in JScript wont do at all,

> Also, maybe this script utility package might help.
>
> http://www.pstruh.cz/help/ScptUtl/library.htm

yes, I've been peeking into that library.
infact, I'm am currenly using the VBS string to conversion methods/logic
from there.
the weird 0x00 result appears to be added at their RecordSet level.
I am pretty new to the ADODB api, is there a way to define encoding for
RecordSets ?

the reason I'd like to achieve this is because I'm in the works if
developing a Binary class supplying
methods to load and save binary code to disk in a WSH env. Currently I have
these going fine:
xmlHTTP -> binary file
binary file -> base64/bin.hex

but would also like :
base64/bin.hex/string -> binary file


Preferrably I would like to end up using no 3rd party software, using
Jscript, ADODB and the
XML objects alone


regards,
Thomas.

Michael Harris (MVP)

unread,
Jan 7, 2002, 8:31:11 PM1/7/02
to
Try using:

Q250344 - SAMPLE: ARRAYCONVERT.EXE Variant Conversion Functions
http://support.microsoft.com/support/kb/articles/Q250/3/44.ASP

which supports converting from a string to a byte array which is what an
binary type stream object expects...

--
Michael Harris
Microsoft.MVP.Scripting
--
"Thomas" <sp...@jet.st> wrote in message
news:a1cp4e$pt16o$1...@ID-12944.news.dfncis.de...

0 new messages