in reply to Re^3: Encoding is a pain.
in thread Encoding is a pain.

Actually, in XML 1.0 CDATA sections are no good for binary data even without the delimiter issue. A CDATA section is defined to contain Chars, which in turn are defined as:

Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000- +#x10FFFF]

So for example control characters in the range 0x00 - 0x08 are not allowed. There are also encoding issues which would prevent you putting binary bytes in CDATA.