CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: BSTR*

  1. #1
    Join Date
    Sep 2003
    Posts
    815

    BSTR*

    Hello,

    I'm allocating a BSTR* like that:

    //-------------------------------------------------------------
    BSTR* bstr
    *bstr = SysAllocStringByteLen(sStlStr.c_str(),(unsigned int)sStlStr.length());

    //sStlStr is std::string holding a string
    //----------------------------------------------------------------

    now when I look at the bstr at the debugger, that's what I see something that look like that (that's only part of the string, this is a very long one):

    㔷㔮䐼呅䥁卌‽‧***************?﫥‧癮㴠✠‧慢敳灟捲㴠✠‧慶畬⁥‽ㄧ㈱㤬㜸‧潣瑳㴠✠‧潣瑳损杮灟湣

    this bstr* is an out parameter for and the function is actually called by a VB client, the VB get this BSTR* as a string of ?
    (pleny of them)

    My question: how can I see the bstr* normally (with the same value as the stl::string)
    I must use bstr* because as I said this code is part of a C++ function that is called from a VB client....

    thanks
    avi
    Last edited by avi123; December 31st, 2003 at 07:25 AM.

  2. #2
    Join Date
    Aug 2002
    Location
    Madrid
    Posts
    4,588
    A BSTR is Unicode while std::string is ANSI. Check the FAQ to see how you convert between them.
    Get this small utility to do basic syntax highlighting in vBulletin forums (like Codeguru) easily.
    Supports C++ and VB out of the box, but can be configured for other languages.

  3. #3
    Join Date
    Sep 2002
    Location
    Maryland - Fear The Turtle!
    Posts
    7,537
    turn on the option to display unicode strings in the VC options should be under the debugger options, though I'm not sure that really is your problem. But just a heads up for debugging and displaying unicode strings.

  4. #4
    Join Date
    Sep 2003
    Posts
    815
    I don't find this option
    can you pls tell me where is it exactly?

    thanks

  5. #5
    Join Date
    Aug 1999
    Posts
    586
    Originally posted by avi123
    I don't find this option
    can you pls tell me where is it exactly?

    thanks
    From the "Tools" menu select "Options", go to the "Debug" property page and check "Display unicode strings".

  6. #6
    Join Date
    Aug 2002
    Location
    Madrid
    Posts
    4,588
    Originally posted by Mick
    turn on the option to display unicode strings in the VC options should be under the debugger options, though I'm not sure that really is your problem. But just a heads up for debugging and displaying unicode strings.
    He must have it enabled already, otherwise he wouldn't have gotten the "㔷㔮䐼呅䥁卌‽‧***************?﫥‧癮㴠✠‧慢敳灟捲㴠✠‧慶畬⁥‽ㄧ㈱㤬㜸‧潣瑳㴠✠‧潣瑳损杮灟湣
    " string.

    Anyways, avi123, you have to convert from ANSI to Unicode, there is no other way. The line "SysAllocStringByteLen(sStlStr.c_str(),(unsigned int)sStlStr.length());" is way wrong and should be replaced by the real conversion.
    Get this small utility to do basic syntax highlighting in vBulletin forums (like Codeguru) easily.
    Supports C++ and VB out of the box, but can be configured for other languages.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured