I have a Data-Url of a file as std:string. The base64 encoded data has to be decoded and then be passed to this function:
open (const byte * data, long size)
So first i extract the encoded data
size_t pos = dataurl.find_first_of(',');
std::string encoded = dataurl.substr(spos + 1);
Then i use this base64 decoder
std::string decoded = base64_decode(encoded);
Well, how can i cast 'decoded' of type string to byte*? The following code produces an error
open((byte *)decoded.c_str(), decoded.size() + 1);
//>>error: 'byte' was not declared in this scope
/EDIT: so there is a typedef
typedef uint8_t byte
the encoded data is an image!
It looks like you are removing const
. c_str()
returns a const char *
. Your cast should be (const byte *)
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With