ascii85 has a function to get the maximum length of an encoding MaxEncodedLen()
.
I think that it should have too a function to get the length at decoding like it has in Base64.
Here's a function to calculate Go package ascii85
MaxDecodedLen()
for n
encoded bytes.
func MaxDecodedLen(n int) int {
const binWordLen = 4
return n * binWordLen
}
If all four bytes of a unencoded group are zero, they are represented by a single byte, the character z
, instead of by five exclamation points (!!!!!
). In some implementations, an unencoded group of spaces may be represented by the single character y
.
ascii85.Decode()
, unlike ascii85.Encode()
, has number of bytes consumed (nsrc
) and flush
parameters, in addition to a number of bytes written (ndst
) parameter, which allows the programmer to decode multiple blocks or a single block piece-by-piece. Therefore, a destination buffer of less than the MaxDecodedLen()
may be used.