Instead of the overhead with saving binary as Base64, I was wondering if you could directly store double-byte binary streams into XML files, using CDATA, or commenting it out, or something?
The Nul character ( '\0' in C ) is not valid anywhere in XML, even as an escape ( & #0; ).
No you can't use CDATA alone to inject binary data in an XML file.
In XML1.0 (because XML 1.1 is more permissive, but not about control chars), the following restrictions apply to CDATA characters:
CData ::= (Char* - (Char* ']]>' Char*))
Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]
That means there are several characters illegal, among them are:
In addition to that, in a standard entity content without CDATA :
é
is OK, &zajdalkdza;
is not)So CDATA is just a way to allow "<", ">" and "&", by restricting "]]>" instead. It doesn't solve the illegal XML, Unicode and UTF-8 characters issue which is the main problem.
Solutions:
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