[Implemented] Flag for Base64Encoder / Decoder...

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

[Implemented] Flag for Base64Encoder / Decoder...

Post 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).
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
User avatar
Kukulkan
Addict
Addict
Posts: 1396
Joined: Mon Jun 06, 2005 2:35 pm
Location: germany
Contact:

Re: Flag for Base64Encoder / Decoder...

Post by Kukulkan »

+1
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Re: Flag for Base64Encoder / Decoder...

Post by Mistrel »

+1!

I've always had to fudge the trailing '=' to get it to validate in XML. This would be so very helpful.
User avatar
kenmo
Addict
Addict
Posts: 2033
Joined: Tue Dec 23, 2003 3:54 am

Re: Flag for Base64Encoder / Decoder...

Post by kenmo »

+1

I've been using a homebrew Url64Encoder() procedure for a while, a built-in flag would be nice.
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Re: Flag for Base64Encoder / Decoder...

Post 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.
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
Post Reply