b64_encode_string Subroutine

private pure subroutine b64_encode_string(s, code)

Encode scalar string to base64.

 use befor64
 use penf
 character(len=:), allocatable :: code64
 call b64_encode(s='hello', code=code64)
 print "(A)", code64

Arguments

Type IntentOptional AttributesName
character(len=*), intent(in) :: s

String to be encoded.

character(len=:), intent(out), allocatable:: code

Encoded scalar.

Calls

proc~~b64_encode_string~~CallsGraph proc~b64_encode_string b64_encode_string byte_size byte_size proc~b64_encode_string->byte_size proc~encode_bits encode_bits proc~b64_encode_string->proc~encode_bits
Help

Called By

proc~~b64_encode_string~~CalledByGraph proc~b64_encode_string b64_encode_string proc~b64_encode_up b64_encode_up proc~b64_encode_up->proc~b64_encode_string interface~b64_encode b64_encode interface~b64_encode->proc~b64_encode_string program~volatile_doctest~11 volatile_doctest program~volatile_doctest~11->interface~b64_encode program~volatile_doctest~34 volatile_doctest program~volatile_doctest~34->interface~b64_encode program~volatile_doctest~4 volatile_doctest program~volatile_doctest~4->interface~b64_encode program~volatile_doctest~10 volatile_doctest program~volatile_doctest~10->interface~b64_encode program~volatile_doctest~37 volatile_doctest program~volatile_doctest~37->interface~b64_encode program~volatile_doctest~5 volatile_doctest program~volatile_doctest~5->interface~b64_encode program~volatile_doctest~13 volatile_doctest program~volatile_doctest~13->interface~b64_encode program~volatile_doctest~9 volatile_doctest program~volatile_doctest~9->interface~b64_encode program~volatile_doctest~2 volatile_doctest program~volatile_doctest~2->interface~b64_encode program~volatile_doctest~35 volatile_doctest program~volatile_doctest~35->interface~b64_encode program~volatile_doctest~6 volatile_doctest program~volatile_doctest~6->interface~b64_encode program~volatile_doctest~14 volatile_doctest program~volatile_doctest~14->interface~b64_encode program~volatile_doctest~3 volatile_doctest program~volatile_doctest~3->interface~b64_encode program~volatile_doctest~36 volatile_doctest program~volatile_doctest~36->interface~b64_encode program~volatile_doctest~7 volatile_doctest program~volatile_doctest~7->interface~b64_encode program~volatile_doctest~8 volatile_doctest program~volatile_doctest~8->interface~b64_encode
Help

Source Code


Source Code

   pure subroutine b64_encode_string(s, code)
   !< Encode scalar string to base64.
   !<
   !<```fortran
   !< use befor64
   !< use penf
   !< character(len=:), allocatable :: code64
   !< call b64_encode(s='hello', code=code64)
   !< print "(A)", code64
   !<```
   !=> aGVsbG8= <<<
   character(*),                  intent(in)  :: s       !< 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)
   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)
   endsubroutine b64_encode_string