Page 1 of 1

[Implemented] Flag for Base64Encoder / Decoder...

Posted: Mon Oct 18, 2010 10:30 am
by DoubleDutch
Could an optional flag be added to specify variants on the Base64 encoding and decoding (see wikipedia for variants):

"Using standard Base64 in URL requires encoding of '+' and '/' characters into special percent-encoded hexadecimal sequences ('+' = '%2B' and '/' = '%2F'), which makes the string unnecessarily longer.

For this reason, a modified Base64 for URL variant exists, where no padding '=' will be used, and the '+' and '/' characters of standard Base64 are respectively replaced by '-' and '_', so that using URL encoders/decoders are no longer necessary and have no impact on the length of the encoded value, leaving the same encoded form intact for use in relational databases, web forms, and object identifiers in general."

(with a new hybrid that (as well as changing the + and / over) changes the ending '=' into a '|' so it can easily be used in any url string - some urls use '=' in parameter exchange - I'm suprised the left it in with the 'official' variant).

Re: Flag for Base64Encoder / Decoder...

Posted: Mon Oct 18, 2010 1:46 pm
by Kukulkan
+1

Re: Flag for Base64Encoder / Decoder...

Posted: Tue Oct 19, 2010 7:57 pm
by Mistrel
+1!

I've always had to fudge the trailing '=' to get it to validate in XML. This would be so very helpful.

Re: Flag for Base64Encoder / Decoder...

Posted: Wed Oct 20, 2010 2:40 am
by kenmo
+1

I've been using a homebrew Url64Encoder() procedure for a while, a built-in flag would be nice.

Re: Flag for Base64Encoder / Decoder...

Posted: Wed Oct 20, 2010 8:46 am
by DoubleDutch
I just use the normal one, then do a ReplaceString - I then do the opposite on the convert back. It would be very handy to have the various types as an option though.