Encode numbers (integer and real) to base64.
This is an interface for encoding integer and real numbers of any kinds into a base64 string. This interface can encode both scalar and array.
The encoded string is returned as varying length character string, character(len=:), allocatable:: string, thus the
compiler must support such a Fortran (2003) feature.
Before start to encode anything the library must be initialized. The procedure b64_init must be called at first. The
global variable is_b64_initialized can be used to check the status of the initialization.
For a practical example see the autotest procedure.
character(len=:), allocatable:: code64 ! base64 encoded string ... call b64_encode(n=12._R8P,code=code64)
character(len=:), allocatable:: code64 ! base64 encoded string ... call b64_encode(n=[12_I4P,1_I4P],code=code64)
If you want to encode heterogenous data (e.g. integer and real numbers), you must use the auxiliary pack_data
procedure.
The encoding of array of strings is admitted only if each string of the array has the same length.
Nodes of different colours represent the following:
Solid arrows point from a procedure to one which it calls. Dashed arrows point from an interface to procedures which implement that interface. This could include the module procedures in a generic interface or the implementation in a submodule of an interface in a parent module.
Nodes of different colours represent the following:
Solid arrows point from a procedure to one which it calls. Dashed arrows point from an interface to procedures which implement that interface. This could include the module procedures in a generic interface or the implementation in a submodule of an interface in a parent module.
Encode scalar number to base64 (R8P).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=R8P), | intent(in) | :: | n | Number to be encoded. |
||
| character(len=:), | intent(out), | allocatable | :: | code | Encoded scalar. |
Encode array numbers to base64 (R8P).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=R8P), | intent(in) | :: | n(1:) | Array of numbers to be encoded. |
||
| character(len=:), | intent(out), | allocatable | :: | code | Encoded array. |
Encode scalar number to base64 (R4P).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=R4P), | intent(in) | :: | n | Number to be encoded. |
||
| character(len=:), | intent(out), | allocatable | :: | code | Encoded scalar. |
Encode array numbers to base64 (R4P).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=R4P), | intent(in) | :: | n(1:) | Array of numbers to be encoded. |
||
| character(len=:), | intent(out), | allocatable | :: | code | Encoded array. |
Encode scalar number to base64 (I8P).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=I8P), | intent(in) | :: | n | Number to be encoded. |
||
| character(len=:), | intent(out), | allocatable | :: | code | Encoded scalar. |
Encode array numbers to base64 (I8P).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=I8P), | intent(in) | :: | n(1:) | Array of numbers to be encoded. |
||
| character(len=:), | intent(out), | allocatable | :: | code | Encoded array. |
Encode scalar number to base64 (I4P).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=I4P), | intent(in) | :: | n | Number to be encoded. |
||
| character(len=:), | intent(out), | allocatable | :: | code | Encoded scalar. |
Encode array numbers to base64 (I4P).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=I4P), | intent(in) | :: | n(1:) | Array of numbers to be encoded. |
||
| character(len=:), | intent(out), | allocatable | :: | code | Encoded array. |
Encode scalar number to base64 (I2P).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=I2P), | intent(in) | :: | n | Number to be encoded. |
||
| character(len=:), | intent(out), | allocatable | :: | code | Encoded scalar. |
Encode array numbers to base64 (I2P).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=I2P), | intent(in) | :: | n(1:) | Array of numbers to be encoded. |
||
| character(len=:), | intent(out), | allocatable | :: | code | Encoded array. |
Encode scalar number to base64 (I1P).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=I1P), | intent(in) | :: | n | Number to be encoded. |
||
| character(len=:), | intent(out), | allocatable | :: | code | Encoded scalar. |
Encode array numbers to base64 (I1P).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=I1P), | intent(in) | :: | n(1:) | Array of numbers to be encoded. |
||
| character(len=:), | intent(out), | allocatable | :: | code | Encoded array. |
Encode scalar string to base64.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | s | String to be encoded. |
||
| character(len=:), | intent(out), | allocatable | :: | code | Encoded scalar. |
Encode array string to base64.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | s(1:) | String to be encoded. |
||
| character(len=:), | intent(out), | allocatable | :: | code | Encoded scalar. |