Item 19. Encode Binary Data Using Quoted Printable and/or Base64
It's questionable whether including binary data in XML documents is a good idea at all. You're often better off just pointing to it with a URL. However, if you do have a genuine need to keep binary information together with text in one document, there are a number of straight forward algorithms for encoding arbitrary byte sequences as text. These include the following:
Only the last two are worth considering. UUEncode is not precisely defined and varies significantly in practice between different implementations . hexBinary is simple to implement, but it at least doubles the size of every file. Quoted printable and Base64 are much more efficient. Quoted printable is suitable for text data that is not well- formed XML. Base64 is suited for truly nontext data like JPEG images or QuickTime movies.