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. Question about binary String ?

Question about binary String ?

Scheduled Pinned Locked Moved C / C++ / MFC
questionxmlhelp
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.
  • S Offline
    S Offline
    Sakthiu
    wrote on last edited by
    #1

    Dear All, I am using MSXML. Here this below function asking binary string. "spText = spDocOutput->createTextNode((_bstr_t)Data);" I have Multibyte/Unicode strings only. How can i write those string in an XML File using this above code ? Kindly Help me. Thanks. Bye.

    C Z V S 4 Replies Last reply
    0
    • S Sakthiu

      Dear All, I am using MSXML. Here this below function asking binary string. "spText = spDocOutput->createTextNode((_bstr_t)Data);" I have Multibyte/Unicode strings only. How can i write those string in an XML File using this above code ? Kindly Help me. Thanks. Bye.

      C Offline
      C Offline
      CPallini
      wrote on last edited by
      #2

      It is not so clear what you intend to do. Anyway, maybe the following overloads of the _bstr_t constructor will be useful:

      _bstr_t::_bstr_t( const char* s2 ) throw( _com_error );

      _bstr_t::_bstr_t( const wchar_t* s3 ) throw( _com_error );

      1 Reply Last reply
      0
      • S Sakthiu

        Dear All, I am using MSXML. Here this below function asking binary string. "spText = spDocOutput->createTextNode((_bstr_t)Data);" I have Multibyte/Unicode strings only. How can i write those string in an XML File using this above code ? Kindly Help me. Thanks. Bye.

        Z Offline
        Z Offline
        Zac Howland
        wrote on last edited by
        #3

        Sakthiu wrote:

        Here this below function asking binary string.

        BSTR is NOT "binary string". BSTR is a string format similar to PASCAL strings where the first 4 bytes of the string specify its length and each character in the string is a wide character (that is, uses 2 bytes).

        If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week Zac

        C 1 Reply Last reply
        0
        • Z Zac Howland

          Sakthiu wrote:

          Here this below function asking binary string.

          BSTR is NOT "binary string". BSTR is a string format similar to PASCAL strings where the first 4 bytes of the string specify its length and each character in the string is a wide character (that is, uses 2 bytes).

          If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week Zac

          C Offline
          C Offline
          CPallini
          wrote on last edited by
          #4

          And it is also NULL terminated. But this is just academia...:)

          1 Reply Last reply
          0
          • S Sakthiu

            Dear All, I am using MSXML. Here this below function asking binary string. "spText = spDocOutput->createTextNode((_bstr_t)Data);" I have Multibyte/Unicode strings only. How can i write those string in an XML File using this above code ? Kindly Help me. Thanks. Bye.

            V Offline
            V Offline
            Viorel
            wrote on last edited by
            #5

            I think you can try the save member of parent DOMDocument object, but it writes the entire XML document, not only your element. If you need just one element, I think you can obtain the XML representation of the node using xml property, probably like this:

            _bstr_t xml = myNode->xml;
            

            Then write this string using file functions. Note that in case of text node, the returned XML string probably will not differ very much from the value you passed to createTextNode function. I hope this helps.

            1 Reply Last reply
            0
            • S Sakthiu

              Dear All, I am using MSXML. Here this below function asking binary string. "spText = spDocOutput->createTextNode((_bstr_t)Data);" I have Multibyte/Unicode strings only. How can i write those string in an XML File using this above code ? Kindly Help me. Thanks. Bye.

              S Offline
              S Offline
              Stephen Hewitt
              wrote on last edited by
              #6

              Don't use casts - especially C-style casts - unless you know exactly what you're doing. If you must cast without fully understanding the ramifications using static_cast instead is safer; but still not safe in all situations. If you want to encode binary data in XML you'll have to encode it. For example you could base64 encode it.

              Steve

              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