views:

949

answers:

3

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?

+4  A: 

The Nul character ( '\0' in C ) is not valid anywhere in XML, even as an escape ( & #0; ).

Pete Kirkham
I suppose because XML files are null-terminated.
Jenko
@Jeremy: They aren't. Null is just not a valid XML character, likely because of null-terminated strings in a popular programming language...
Christoph
Note that the standard is not 100% clear about this. The character range definitions exclude the 0 byte but some other texts say that any character below 127 is valid.
Aaron Digulla
@Aaron: http://www.w3.org/TR/xml/#charsets should be pretty clear...
Christoph
+2  A: 
João da Silva
Doesn't that mean no you can't, since 0-8,B,C,E,F FFFE, and FFFF are invalid characters?
David Sykes
+3  A: 

XML is a plain-text format - don't use it to store binary data. Put the binary blobs in separate files and add an element to your XML which references these files. If you want to store all binary blobs in a single file, add an offset attribute or something like that...

Christoph
Yeah, and exactly how is Flash supposed to connect to and read raw binary off files? (ActionScript 2 only)
Jenko
Don't give me the ByteArray or URLLoader talk. This is AS2 only.
Jenko
@Jeremy: and where exactly did you state that in your question?
Christoph
I didn't because I wanted to be open about AS2/AS3 so hopefully get more answers.
Jenko