Item 19. Encode Binary Data Using Quoted Printable andor Base64

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:

  • UUEncode

  • hexBinary

  • Quoted printable

  • Base64

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.



Effective XML. 50 Specific Ways to Improve Your XML
Effective XML: 50 Specific Ways to Improve Your XML
ISBN: 0321150406
EAN: 2147483647
Year: 2002
Pages: 144

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net