I'm trying to convert a png file to a base64 but when I'm write the output to a file, I have a lot of backslash like this : data:image\/png;base64
My code :
string encoded_png;
Mat img; // Load an image here
vector<uchar> buf;
cv::imencode(".png", img, buf);
auto base64_png = reinterpret_cast<const unsigned char*>(buf.data());
encoded_png = "data:image/png;base64," + base64_encode(base64_png, buf.size());
Escaping /
as \/
is perfectly valid in JSON. Any parser should interpret the escaped character as just a /
.