Base64 support in DataSection

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
codeprof
User
User
Posts: 65
Joined: Sun Sep 16, 2012 12:13 pm

Base64 support in DataSection

Post by codeprof »

It would be cool if PureBasic would support Base64 encoded data in the DataSection.
This would have 2 advantages:
- shorter
- it is easy to create the base64 string

Code: Select all

DataSection
  MyData:
  Data.Base64 "ZHNnZGdzZGhkc2Fpc2hmaWFzZiAyMyAwMnQwNDJoMPwgCUhHIEdJSCBHSCBHSMQgJKciSUggRyQgSaciIA=="
EndDataSection
User avatar
Shield
Addict
Addict
Posts: 1021
Joined: Fri Jan 21, 2011 8:25 am
Location: 'stralia!
Contact:

Re: Base64 support in DataSection

Post by Shield »

Why would this be useful?
Base64 just makes the amount of data larger (about 33%).
There is, in my opinion, no point in including data encoded in Base64.

To work with the data you need to decode it anyway, so why not just leave it decoded?
This saves processing overhead and storage overhead.

-1
Image
Blog: Why Does It Suck? (http://whydoesitsuck.com/)
"You can disagree with me as much as you want, but during this talk, by definition, anybody who disagrees is stupid and ugly."
- Linus Torvalds
codeprof
User
User
Posts: 65
Joined: Sun Sep 16, 2012 12:13 pm

Re: Base64 support in DataSection

Post by codeprof »

The advantage is to place small binary data (like png files) directly in the PureBasic source (e.g. for forum post).
At the moment I need to call Base64Decoder() and even worser I must allocate a secound buffer to store the decrypted data.
It would be cool if the compiler translates it automatically to binary data.

Of course I can include binary data with Data.q etc, like:

Code: Select all

DataSection
  MyData:
  Data.q $ff32a557fc3789753, $32654a557fc3789753
  Data.b $aa, $bb, $cc
EndDataSection
However this has many disadvantages.
- I need a special program which builds the PureBasic code (the Base64 of a file can be generated easyly)
- If the size of the file is not divisible by 8, I have to use additinal Data.b at the end (so it is not easy for PB beginners....)
- even Data.q needs more place than base64 encoded strings (200% compared to the size of binary data + overhead)
Base64 needs just 133%
Post Reply