This question isn't about the decoded data, but about *which* base64 format is used - i.e. if it uses padding or not and what 2 characters are used outside of a-zA-Z0-9. The most common ones use +/ and -_, so it's easy to tell which is used and just accept either (and padding can be viewed as optional during decoding anyway).
On Tue, Feb 2, 2021 at 2:37 PM Robert Engels <reng...@ix.netcom.com> wrote: > Base64 is always ASCII. The encoded data may be in an arbitrary format. > You need to pass additional metadata or try and detect its encoding. > > On Feb 2, 2021, at 6:50 AM, roger peppe <rogpe...@gmail.com> wrote: > > > In case you find it helpful, here's a clone of the base64 command that I > wrote in Go. I did it precisely because I wanted to be able to decode any > encoding scheme interchangeably. > > https://github.com/rogpeppe/misc/blob/master/cmd/base64/base64.go > > I agree that it might be useful to have some of this functionality > available in the standard library. > > cheers, > rog. > > On Tue, 2 Feb 2021 at 09:08, hey...@gmail.com <hey....@gmail.com> wrote: > >> Hi, >> >> I have an io.Reader whose content is encoded in base64 with encoding type >> unknown. Since there shouldn't be any ambiguity between the two, is it >> possible to make the base64 automatically pick the right one to decode? >> >> Currently I have to read everything out to pin down the encoding, which >> defeats the purpose of using an io.Reader. >> >> Is there a solution to this problem? >> >> Thanks in advance. >> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "golang-nuts" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to golang-nuts+unsubscr...@googlegroups.com. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/golang-nuts/0ccee37d-319e-41b3-9bfd-3dc46e0fad78n%40googlegroups.com >> <https://groups.google.com/d/msgid/golang-nuts/0ccee37d-319e-41b3-9bfd-3dc46e0fad78n%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/CAJhgacjkUUSr-dOPFU-W4vG_AXZRY_dYYe2ti-iPuu_XUL%2BNVw%40mail.gmail.com > <https://groups.google.com/d/msgid/golang-nuts/CAJhgacjkUUSr-dOPFU-W4vG_AXZRY_dYYe2ti-iPuu_XUL%2BNVw%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/CF76EF37-6F82-42FF-B4D6-4B9FC02F25FC%40ix.netcom.com > <https://groups.google.com/d/msgid/golang-nuts/CF76EF37-6F82-42FF-B4D6-4B9FC02F25FC%40ix.netcom.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAEkBMfGFqX_aBoecB-BAMeFaDVQJnMh%2BbxTMig4wyBuM5RLWOw%40mail.gmail.com.