Writing binary data (CString) to file

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Carl Forsman

    Writing binary data (CString) to file

    I have some binary data encoded as Base64 encoding in an XML element
    like this:

    <data>TWFuIGlzI GRpc3Rpbmd1aXNo ZWQsIG5vdCBvbmx </data>

    how can I extract this data -
    TWFuIGlzIGRpc3R pbmd1aXNoZWQsIG 5vdCBvbmx

    and save to a file say test2.xml

    =============== ===
    pug::xml_node_l ist CategoryEntries ;
    PictureEntries[i].all_elements_b y_name("categor y", CategoryEntries );

    // if found XML element
    if (CategoryEntrie s.size() 0) {
    for (unsigned int i = 0; i < CategoryEntries .size(); i++) {

    //extract the Base64 string from XML element
    //this Base64 string has binary data after decode
    CString cat = CategoryEntries[i].child(0).value ();

    //decode Base64 string into binary data
    CString decoded = decodeBase64(ca t);

    //open file to write the binary data
    std::ofstream file1("c:/test2.xml");

    // write the decoded binary data to file
    file1.write(dec oded);

    }
    }
Working...