Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | s(1:) | String to be encoded. |
||
character(len=:), | intent(out), | allocatable | :: | code | Encoded scalar. |
Encode array string to base64.
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
integer(kind=I1P), | public, | allocatable | :: | nI1P(:) | One byte integer array containing n. |
||
integer(kind=I4P), | public | :: | padd | Number of padding characters ('='). |
|||
integer(kind=I4P), | public | :: | BYCHS | Bytes of character string. |
pure subroutine b64_encode_string_a(s, code)
!---------------------------------------------------------------------------------------------------------------------------------
!< Encode array string to base64.
!---------------------------------------------------------------------------------------------------------------------------------
character(*), intent(in) :: s(1:) !< String to be encoded.
character(len=:), allocatable, intent(out) :: code !< Encoded scalar.
integer(I1P), allocatable :: nI1P(:) !< One byte integer array containing n.
integer(I4P) :: padd !< Number of padding characters ('=').
integer(I4P) :: BYCHS !< Bytes of character string.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
BYCHS = byte_size(s(1))*size(s,dim=1)
allocate(nI1P(1:((BYCHS+2)/3)*3)) ; nI1P = 0_I1P
code = repeat(' ',((BYCHS+2)/3)*4)
nI1P = transfer(s,nI1P)
padd = mod((BYCHS),3_I4P) ; if (padd>0_I4P) padd = 3_I4P - padd
call encode_bits(bits=nI1P,padd=padd,code=code)
return
!---------------------------------------------------------------------------------------------------------------------------------
endsubroutine b64_encode_string_a