Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Poco::Base64Decoder stream not returning complete string

not sure if i am just using it wrong because this is not really my field of expertise but i was under the impression that this should give me a complete decoded openframeworks buffer (or a simple string, i tried various ways all resulting in the same too short string):

string str; // string is a line from a file handle and shows to be ok in the debugger
istringstream istr(str);
Poco::Base64Decoder b64in(istr);
ofBuffer buffer;
b64in >> buffer;

now an example base64 string i am decoding is this line:

I2J1bmRsZQAAAAAAAAAAAQAAABwvT1NDL1NwYWNlSW50ZW5zaXR5ACxmAAA6nUlSAAAAFC9PU0MvU3BlZWQAACxmAAA90/fPAAAAGC9PU0MvU21vb3RobmVzcwAsZgAAP2Wu5gAAABQvT1NDL1JlYWNoAAAsZgAAPnxQSAAAABgvT1NDL0RlbnNpdHkAAAAALGYAAAAAAAAAAAAYL09TQy9Db2hlcmVuY2UAACxmAAA+tYEGAAAAIC9PU0MvVHJhdmVsSW50ZW5zaXR5AAAAACxmAAA8eQlsAAAAFC9PU0MvUmh5dGhtACxmAAA+6LQ5AAAAGC9PU0MvSGFybW9ueQAAAAAsZgAAPui0OQAAABQvT1NDL0VuZXJneQAsZgAAPYznBA==

the line does not resolve to a simple ascii text but rather a raw osc packet dumped in base64 by some vvvv patch i do not have access to... so i guess it could also be an encoding issue?

and all i get in the output, no matter if i use a streamcopier or an operator like above, is only "#bundle". could this somehow be related to the / character or other non-standard stuff following the "#bundle"? i was under the impression that the Base64Decoder doesn't care about whitespace or whatever it finds in the decoded data.

like image 853
DasAntonym Avatar asked Dec 26 '22 12:12

DasAntonym


1 Answers

so i ended up not using the operator but rather copying the output of the base64decoder to a stream and then getting a string from that:

istringstream istr(str);
ostringstream ostr;
Poco::Base64Decoder b64in(istr);
copy(std::istreambuf_iterator<char>(b64in),
    std::istreambuf_iterator<char>(),
    std::ostreambuf_iterator<char>(ostr));
cout << ostr.str(); // returns full decoded output
like image 145
DasAntonym Avatar answered Jan 10 '23 13:01

DasAntonym