Groups | Blog | Home
all groups > inetserver asp general > march 2006 >

inetserver asp general : how to display a BSTR string returned by c++ component in HTML


babu17
3/29/2006 2:32:13 AM
hi,

i have an asp page which creates a object using server.createobject and
uses its method.

example:

set obj1= server.createobject("test.test") ' test is a dll
tmp = obj1.method() ' it returns a BSTR string.

i want to display tmp in HTML. when i tried to print tmp like
<font><%=tmp%></font>

i get some garbage value.
any idea.
thanks
Anthony Jones
3/29/2006 1:31:24 PM

[quoted text, click to view]

A BSTR is the native string data type used by ASP scripts.

<%=tmp%>

Is a reasonable way to send the string to the client. However the string
will be converted to the current Response or Session CodePage. This
defaults to the servers system codepage.

If tmp is holding say some Cryllic characters and you attempt to write to
the client whilst the current response codepage is Western Latin then you
can expect to see garbage.

Anthony.

Egbert Nierop (MVP for IIS)
3/29/2006 10:55:42 PM

[quoted text, click to view]

it would be a good idea to show us the C++ component code.
Most times this goes wrong, the programmer assumes that a BSTR is a LPWSTR
or faulty encodes
obj1.method()


[quoted text, click to view]
abcd
4/12/2006 1:48:38 PM
In C++ method you can use BSTR CopyTo call this allocates the new fresh
string and u can see it in asp page

"Egbert Nierop (MVP for IIS)" <egbert_nierop@nospam.invalid> wrote in
message news:eOXNuM3UGHA.736@TK2MSFTNGP12.phx.gbl...
[quoted text, click to view]

AddThis Social Bookmark Button