The official format specification has dropped support for
hex-encoded fields and we never used that format when
marshaling, so remove the code for it.
Also be more intelligent about when to use base64-encoding.
Some strings that are valid UTF-8 nonetheless encode as longer
than their base64-encoded counterparts (for example "\x03\x00"
as seen in a caveat id, encodes to the JSON string "\u0003\u0000".
The official format specification has dropped support for hex-encoded fields and we never used that format when marshaling, so remove the code for it.
Also be more intelligent about when to use base64-encoding. Some strings that are valid UTF-8 nonetheless encode as longer than their base64-encoded counterparts (for example "\x03\x00" as seen in a caveat id, encodes to the JSON string "\u0003\u0000".