title: javax.xml.bind's Base64 encoder/decoder eats last two characters of string
body: <p>I need to convert some strings using Base64 encoding, and was delighted to see that I didn't have to roll my own converter--Java provides one with <code>javax.xml.bind.DataConverter</code>. However, it has some problems. Here's the output of my time with a Jython REPL:</p>
  
  <pre><code>&gt;&gt;&gt; import javax.xml.bind.DatatypeConverter as DC
  &gt;&gt;&gt; import java.lang.String as String
  &gt;&gt;&gt; def foo(text):
  ...   return DC.printBase64Binary(DC.parseBase64Binary(String(text)))
  ... 
  &gt;&gt;&gt; foo("hello")
  'hell'
  &gt;&gt;&gt; foo("This, it's a punctuated sentence.")
  'Thisitsapunctuatedsenten'
  &gt;&gt;&gt; foo("\"foo\" \"bar\"")
  'foob'
  &gt;&gt;&gt; foo("\"foo\" \"bar\"12")
  'foobar12'
  &gt;&gt;&gt; foo("\"foo\" \"bar\"1")
  'foob'
  </code></pre>
  
  <p>As you can see, it doesn't handle non-alphanumeric characters at all, and also frequently--but not always--truncates the string by two characters.</p>
  
  <p>I guess it might be time to just write my own class, but now I'm bothered that either a) I'm failing at reading the javadoc or something b) The class doesn't work as expected.</p>
  
  <p>So any help is much appreciated; thanks in advance.</p>