The way I see it, forget that the file is an SVG file; don't think of the problem as conversion, but just as reading a file into a QByteArray. Just create a QBytearray and read the file into it, not caring what the contents are.
The way I see it, forget that the file is an SVG file; don't think of the problem as conversion, but just as reading a file into a QByteArray. Just create a QBytearray and read the file into it, not caring what the contents are.
meazza (5th July 2011)
I am not sure why you would want to Base64 encode an SVG file: it is already text after all.
Qt Code:
input.close(); output.write(ba.toBase64()); output.close(); }To copy to clipboard, switch view to plain text mode
meazza (5th July 2011)
Well I have an application where you can load different types of images (svg, pbg and jpg) and I am saving PNG and JPG base64 encoded to an xml document so thought might aswell do that to the SVG images aswell.I am not sure why you would want to Base64 encode an SVG file: it is already text after all.
Am I losing something when I do this or?
If you are doing this to store an arbitrary binary blob inside another text format then this is a reasonable way to do it. You should not be losing anything except a little bit of disk space for the large Base64 version.
Bookmarks