Board index » cppbuilder » Converting a binary data to AnsiString in Active Object Serve

Converting a binary data to AnsiString in Active Object Serve

I use a function in a COM bject (a third party tool) that returned binary
data.
All of them is only HTML text. For outputint this stream I use the
Response.BinaryWrite(my data);.
But I need to convert it to AnsiString or char * for making any change
inside and then outputint the result.
I have create this COM method foir doing this stuff:

STDMETHODIMP TCustomToolsImpl::SearchReplace(TVariant* myBinaryDataText)
{
        WideString Str1=myBinaryDataText->bstrVal;//Geting the data in a
WideString
         Str2=(AnsiString)Str1;//Converting in AnsiSytring
        ... (making any change)

        Response.Write(Str2)

Quote
}

No my problem is that the result is not texte data. It seems to be always
binary data because the Response.Write() outputs only strange 2 or 4 octets.

What is wrng ?

Thanks for help.

Sam

 

Re:Converting a binary data to AnsiString in Active Object Serve


Quote
Sam wrote:

> I use a function in a COM bject (a third party tool) that returned binary
> data.
> All of them is only HTML text.

HTML text is just ascii text and not binary data.

Quote
> For outputint this stream

Is it a stream ? You consider it a TVariant.

Quote
> I use the
> Response.BinaryWrite(my data);.
> But I need to convert it to AnsiString or char * for making any change
> inside and then outputint the result.
> I have create this COM method foir doing this stuff:

> STDMETHODIMP TCustomToolsImpl::SearchReplace(TVariant* myBinaryDataText)
> {
>         WideString Str1=myBinaryDataText->bstrVal;//Geting the data in a
> WideString

Are you sure you will get it in a WideString ?
Will this do a conversion ?

If it is binary data you shouls only bother to get a pointer to
that data an knowing the length of the data.

Quote
>          Str2=(AnsiString)Str1;//Converting in AnsiSytring
>         ... (making any change)

Where do you convert from binary to text ?
Which changes did you apply ?

Quote

>         Response.Write(Str2)
> }
> No my problem is that the result is not texte data. It seems to be always
> binary data because the Response.Write() outputs only strange 2 or 4 octets.

> What is wrng ?

You didn't do a conversion from binary to text.
Do you know how the binary data is build up and
in wich way you want to convert that binary represantation
to ascii ?

Hans.

Re:Converting a binary data to AnsiString in Active Object Serve


Quote
> You didn't do a conversion from binary to text.
> Do you know how the binary data is build up and
> in wich way you want to convert that binary represantation
> to ascii ?

This data is UNICODE, so how converting Unicode to AnsiString for example ?

Sam

"Hans Galema" <j.m.gal...@maartens.nl> a crit dans le message news:
3C669D52.ED286...@maartens.nl...

Quote
> Sam wrote:

> > I use a function in a COM bject (a third party tool) that returned
binary
> > data.
> > All of them is only HTML text.

> HTML text is just ascii text and not binary data.

> > For outputint this stream

> Is it a stream ? You consider it a TVariant.

> > I use the
> > Response.BinaryWrite(my data);.

> > But I need to convert it to AnsiString or char * for making any change
> > inside and then outputint the result.
> > I have create this COM method foir doing this stuff:

> > STDMETHODIMP TCustomToolsImpl::SearchReplace(TVariant* myBinaryDataText)
> > {
> >         WideString Str1=myBinaryDataText->bstrVal;//Geting the data in a
> > WideString

> Are you sure you will get it in a WideString ?
> Will this do a conversion ?

> If it is binary data you shouls only bother to get a pointer to
> that data an knowing the length of the data.

> >          Str2=(AnsiString)Str1;//Converting in AnsiSytring
> >         ... (making any change)

> Where do you convert from binary to text ?
> Which changes did you apply ?

> >         Response.Write(Str2)
> > }
> > No my problem is that the result is not texte data. It seems to be
always
> > binary data because the Response.Write() outputs only strange 2 or 4
octets.

> > What is wrng ?

> You didn't do a conversion from binary to text.
> Do you know how the binary data is build up and
> in wich way you want to convert that binary represantation
> to ascii ?

> Hans.

Re:Converting a binary data to AnsiString in Active Object Serve


Quote
Sam wrote:

> This data is UNICODE, so how converting Unicode to AnsiString for example ?

I don't know.

Some people quote the complete original message which most times
is not necessary. You even double a part of the original message.

Please don't do unusefull quotes.

Hans.

Re:Converting a binary data to AnsiString in Active Object Serve


Hello, Sam!

 S> This data is UNICODE, so how converting Unicode to AnsiString for
 S> example ?

WideCharToMultiByte

--
Best regards,

Victor

Re:Converting a binary data to AnsiString in Active Object Serve


Or use the WideString() class

Gambit

"Victor A. Kazakov" <vic...@kazakov.net> wrote in message
news:3c76038b$1_2@dnews...

Quote
> WideCharToMultiByte

Other Threads