Page 1 of 1

Base64 support in DataSection

Posted: Tue Mar 05, 2013 8:26 am
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

Re: Base64 support in DataSection

Posted: Tue Mar 05, 2013 8:50 am
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

Re: Base64 support in DataSection

Posted: Tue Mar 05, 2013 9:12 am
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%