I'm writing my own BASE64 encoder/decoder for some constrained environments.
And I found that Base64.Encoder#encodeString saying that it uses ISO-8859-1
for construct a String from those encoded bytes.
I perfectly presuming that ISO-8859-1
charset also covers all base64 alphabets.
Is there any possible reason not to use US-ASCII
?
I suspect it's more efficient: converting from ISO-8859-1 back to text is just a matter of promoting each byte
straight to a char
, whereas for ASCII you'd need to check that the byte
is valid ASCII. The result for base64 will always be the same, of course.
(That's only a guess, but an educated one. You could always run benchmarks if you want to validate it...)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With