Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How do you TRACE() a BSTR??

How do you TRACE() a BSTR??

Scheduled Pinned Locked Moved C / C++ / MFC
debuggingquestion
6 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Anders Gustafsson
    wrote on last edited by
    #1

    Where Name is a BSTR: TRACE("\nFIELD[%d]: %s",j,(LPCTSTR)Name); or TRACE("\nFIELD[%d]: %s",j,Name); Both just print the first char?? Anders G

    C J M T 4 Replies Last reply
    0
    • A Anders Gustafsson

      Where Name is a BSTR: TRACE("\nFIELD[%d]: %s",j,(LPCTSTR)Name); or TRACE("\nFIELD[%d]: %s",j,Name); Both just print the first char?? Anders G

      C Offline
      C Offline
      Chris Losinger
      wrote on last edited by
      #2

      i think this will do it: TRACE("%S", myBeaster);

      image processing toolkits | batch image processing | blogging

      A 1 Reply Last reply
      0
      • C Chris Losinger

        i think this will do it: TRACE("%S", myBeaster);

        image processing toolkits | batch image processing | blogging

        A Offline
        A Offline
        Anders Gustafsson
        wrote on last edited by
        #3

        It did! Thanks!! This basic stuff is slowly polluting our pure C++ world ;)

        1 Reply Last reply
        0
        • A Anders Gustafsson

          Where Name is a BSTR: TRACE("\nFIELD[%d]: %s",j,(LPCTSTR)Name); or TRACE("\nFIELD[%d]: %s",j,Name); Both just print the first char?? Anders G

          J Offline
          J Offline
          Jorgen Sigvardsson
          wrote on last edited by
          #4

          a BSTR is a UTF-16 (or is it UCS2? can't remember) encoded string. This means that each character is a 2 byte word. The ASCII character set fits within a single byte of each word. As such, from a char* point of view, a BSTR is basically a string with a \0 character between every character. Hence you get only the first character.

          1 Reply Last reply
          0
          • A Anders Gustafsson

            Where Name is a BSTR: TRACE("\nFIELD[%d]: %s",j,(LPCTSTR)Name); or TRACE("\nFIELD[%d]: %s",j,Name); Both just print the first char?? Anders G

            M Offline
            M Offline
            Michael Dunn
            wrote on last edited by
            #5

            %S will work as long as you are calling an ANSI trace function. %S means "a string in the character set opposite of the current TCHAR character set". To make it work in all cases, use %ls instead.

            --Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ Ford, what's this fish doing in my ear?

            1 Reply Last reply
            0
            • A Anders Gustafsson

              Where Name is a BSTR: TRACE("\nFIELD[%d]: %s",j,(LPCTSTR)Name); or TRACE("\nFIELD[%d]: %s",j,Name); Both just print the first char?? Anders G

              T Offline
              T Offline
              ThatsAlok
              wrote on last edited by
              #6

              Anders Gustafsson wrote:

              Where Name is a BSTR: TRACE("\nFIELD[%d]: %s",j,(LPCTSTR)Name);

              TRACE("\nFIELD[%d]: %s",j,(LPCTSTR)_bstr_t(Name));

              "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

              cheers, Alok Gupta Global Interface Table: An Easy Way to Marshal an Interface Pointer[new] VC Forum Q&A :- I/ IV Support CRY- Child Relief and You

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups