b64_encode_string Subroutine

private pure subroutine b64_encode_string(s, code)

Arguments

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

String to be encoded.

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

Encoded scalar.

Description

Encode scalar string to base64.

Calls

proc~~b64_encode_string~~CallsGraph proc~b64_encode_string b64_encode_string interface~byte_size byte_size proc~b64_encode_string->interface~byte_size proc~encode_bits encode_bits proc~b64_encode_string->proc~encode_bits proc~byte_size_i8p byte_size_I8P interface~byte_size->proc~byte_size_i8p proc~byte_size_i4p byte_size_I4P interface~byte_size->proc~byte_size_i4p proc~byte_size_chr byte_size_chr interface~byte_size->proc~byte_size_chr proc~byte_size_r4p byte_size_R4P interface~byte_size->proc~byte_size_r4p proc~byte_size_r8p byte_size_R8P interface~byte_size->proc~byte_size_r8p proc~byte_size_i2p byte_size_I2P interface~byte_size->proc~byte_size_i2p proc~byte_size_i1p byte_size_I1P interface~byte_size->proc~byte_size_i1p
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 proc~autotest autotest proc~autotest->interface~b64_encode proc~encode encode proc~encode->interface~b64_encode
Help

Variables

TypeVisibility AttributesNameInitial
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.


Source Code

  pure subroutine b64_encode_string(s, code)
  !---------------------------------------------------------------------------------------------------------------------------------
  !< Encode scalar string to base64.
  !---------------------------------------------------------------------------------------------------------------------------------
  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)
  return
  !---------------------------------------------------------------------------------------------------------------------------------
  endsubroutine b64_encode_string