Description
Popular visualization formats like the VTK XML File Format use Base64 encoding of numerical data as text. This slightly increases the amount of storage, but proves to be more reliable when distributing data via channels that predominantly support text (e.g. the internet). Another example use case would be embedding binary data (e.g. images, other binary assets) in HTML reports generated by a Fortran program.
The idea was suggested here:
As the user "rwmsu" has stated in that thread:
This would be a big help for writing things like the VTK XML format files where you want to mix base64 encoded binary with standard text. I presume it would have to be an option on the read and/or write statement. something like
Write(iunit, *) ‘’ Write(iunit, *, ENCODE=“base64”) some_real_array
etc.
Having that capability in a compiler would have saved me the time and the almost 1000 lines of code it took to develop my own base64 encoding/decoding package.
Right now, available libraries for Base64 encoding include:
- https://github.com/szaghi/BeFoR64 (in Fortran)
- https://github.com/tobiaslocker/base64 (via C binding)
- https://github.com/aklomp/base64 (via C binding)
- https://github.com/zhicheng/base64 (via C binding, suggested here: https://stackoverflow.com/questions/73452098/fortran-write-base64-string-of-binary-to-file)