how to convert a base64 text to be a binary file

how to convert a base64 text to be a binary file

Post by simo » Fri, 04 May 2001 18:12:09



Hi,

File is attached as base64 format and how can I save it as a binary file?  
Thanks in advance!

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

 
 
 

how to convert a base64 text to be a binary file

Post by David Marteinso » Sat, 05 May 2001 00:07:25



Quote:> File is attached as base64 format and how can I save it as a binary file?

Have a peek at:

http://support.microsoft.com/support/kb/articles/q254/3/88.asp

Regards,

    -djm



 
 
 

how to convert a base64 text to be a binary file

Post by <tr.. » Sat, 05 May 2001 00:34:36


Quote:-----Original Message-----

Hi,

File is attached as base64 format and how can I save it as a binary file?  
Thanks in advance!

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
.
I'm having a simlar problem.  I'm trying to encode a binary file base64 in C++.  
Does the MSXML parser provide the base64 encoding in C++ as the example in VB
suggest (provided by the link on the other reply) or do you need to encode the
binary information first.  If so how does it work and what paramters does it
except.  

 
 
 

how to convert a base64 text to be a binary file

Post by David Marteinso » Sat, 05 May 2001 00:44:36



Quote:>I'm having a simlar problem.  I'm trying to encode a binary file base64 in

C++.

No reason you can't do the same thing in C++, just translate the VB code to
C++.

Regards,

    -djm


 
 
 

how to convert a base64 text to be a binary file

Post by Tren » Sat, 05 May 2001 01:44:04


-----Original Message-----


>I'm having a simlar problem.  I'm trying to encode a binary file base64 in
C++.

No reason you can't do the same thing in C++, just translate the VB code to
C++.

Regards,

    -djm


.
I have translated the VB code into C++ but i haven't been able to create binary
information that the NodeValueType fucntion will except.  Any ideas how i can
create this required binary data.  I beleive it is looking for VARIANT array
(VT_ARRAY | VT_UI1) of binary data.  Either that is wrong or i'm not creating a
variant of binary data.

needless to say i'm getting frustrated.

thanks

Thanks

 
 
 

how to convert a base64 text to be a binary file

Post by Martin Naughto » Sat, 05 May 2001 04:14:10


Hi,

I'm not sure if this contradicts what you described in C++, but a VB Array
is a SAFEARRAY.

The element type is as you describe (Byte=VT_UI1).

Cheers,
Martin


-----Original Message-----


>I'm having a simlar problem.  I'm trying to encode a binary file base64 in
C++.

No reason you can't do the same thing in C++, just translate the VB code to
C++.

Regards,

    -djm


.
I have translated the VB code into C++ but i haven't been able to create
binary
information that the NodeValueType fucntion will except.  Any ideas how i
can
create this required binary data.  I beleive it is looking for VARIANT array
(VT_ARRAY | VT_UI1) of binary data.  Either that is wrong or i'm not
creating a
variant of binary data.

needless to say i'm getting frustrated.

thanks

Thanks

 
 
 

how to convert a base64 text to be a binary file

Post by David Marteinso » Sat, 05 May 2001 04:45:39



I have translated the VB code into C++ but i haven't been able to create
binary
information that the NodeValueType fucntion will except.  Any ideas how i
can
create this required binary data.  I beleive it is looking for VARIANT array
(VT_ARRAY | VT_UI1) of binary data.  Either that is wrong or i'm not
creating a
variant of binary data.

Yes, it sounds like you're very close.  Maybe it's just setting up the
SAFEARRAY that's holding you up?

Here's a code snippet:

 oEle->put_dataType( L"bin.base64" ) ;
  VARIANT vrtBase64 ;
  ::VariantInit( &vrtBase64 ) ;

  SAFEARRAY *psa ;

 // set length based on actual length of object; set to 2 for demo
  psa = ::SafeArrayCreateVector( VT_UI1, 0L, 2 ) ;

  BYTE *chArray ;
  SafeArrayAccessData ( psa , (void **)&chArray );

 // copy in your actual data
  chArray[ 0 ] = 0x65 ;
  chArray[ 1 ] = 0x66 ;

  ::SafeArrayUnaccessData( psa ) ;

 // pop the SAFEARRAY into the VARIANT
  vrtBase64.vt = VT_ARRAY | VT_UI1 ;
  vrtBase64.parray = psa ;

  oEle->put_nodeTypedValue( vrtBase64 ) ;

    // resultant element output should contain: "ZWY="

Regards,

    -djm


 
 
 

how to convert a base64 text to be a binary file

Post by Tren » Sat, 05 May 2001 07:00:07


-----Original Message-----


I have translated the VB code into C++ but i haven't been able to create
binary
information that the NodeValueType fucntion will except.  Any ideas how i
can
create this required binary data.  I beleive it is looking for VARIANT array
(VT_ARRAY | VT_UI1) of binary data.  Either that is wrong or i'm not
creating a
variant of binary data.

Yes, it sounds like you're very close.  Maybe it's just setting up the
SAFEARRAY that's holding you up?

Here's a code snippet:

 oEle->put_dataType( L"bin.base64" ) ;
  VARIANT vrtBase64 ;
  ::VariantInit( &vrtBase64 ) ;

  SAFEARRAY *psa ;

 // set length based on actual length of object; set to 2 for demo
  psa = ::SafeArrayCreateVector( VT_UI1, 0L, 2 ) ;

  BYTE *chArray ;
  SafeArrayAccessData ( psa , (void **)&chArray );

 // copy in your actual data
  chArray[ 0 ] = 0x65 ;
  chArray[ 1 ] = 0x66 ;

  ::SafeArrayUnaccessData( psa ) ;

 // pop the SAFEARRAY into the VARIANT
  vrtBase64.vt = VT_ARRAY | VT_UI1 ;
  vrtBase64.parray = psa ;

  oEle->put_nodeTypedValue( vrtBase64 ) ;

    // resultant element output should contain: "ZWY="

Regards,

    -djm


Thank You David

I did have problems with my variant array and i saw the fix in you code...

Thankyou very much

Trent
.