encode Function

private elemental function encode(self, codec) result(encoded)

Arguments

TypeIntentOptionalAttributesName
class(string), intent(in) :: self
character(kind=CK,len=*), intent(in) :: codec

Return Value type(string)


Calls

proc~~encode~~CallsGraph proc~encode encode interface~b64_encode b64_encode proc~encode->interface~b64_encode proc~b64_encode_r8 b64_encode_R8 interface~b64_encode->proc~b64_encode_r8 proc~b64_encode_r4_a b64_encode_R4_a interface~b64_encode->proc~b64_encode_r4_a proc~b64_encode_i2_a b64_encode_I2_a interface~b64_encode->proc~b64_encode_i2_a proc~b64_encode_i8_a b64_encode_I8_a interface~b64_encode->proc~b64_encode_i8_a proc~b64_encode_i4_a b64_encode_I4_a interface~b64_encode->proc~b64_encode_i4_a proc~b64_encode_i1_a b64_encode_I1_a interface~b64_encode->proc~b64_encode_i1_a proc~b64_encode_string_a b64_encode_string_a interface~b64_encode->proc~b64_encode_string_a proc~b64_encode_i8 b64_encode_I8 interface~b64_encode->proc~b64_encode_i8 proc~b64_encode_r8_a b64_encode_R8_a interface~b64_encode->proc~b64_encode_r8_a proc~b64_encode_r4 b64_encode_R4 interface~b64_encode->proc~b64_encode_r4 proc~b64_encode_i4 b64_encode_I4 interface~b64_encode->proc~b64_encode_i4 proc~b64_encode_i2 b64_encode_I2 interface~b64_encode->proc~b64_encode_i2 proc~b64_encode_i1 b64_encode_I1 interface~b64_encode->proc~b64_encode_i1 proc~b64_encode_string b64_encode_string interface~b64_encode->proc~b64_encode_string proc~encode_bits encode_bits proc~b64_encode_r8->proc~encode_bits proc~b64_encode_r4_a->proc~encode_bits proc~b64_encode_i2_a->proc~encode_bits proc~b64_encode_i8_a->proc~encode_bits proc~b64_encode_i4_a->proc~encode_bits proc~b64_encode_i1_a->proc~encode_bits proc~b64_encode_string_a->proc~encode_bits interface~byte_size byte_size proc~b64_encode_string_a->interface~byte_size proc~b64_encode_i8->proc~encode_bits proc~b64_encode_r8_a->proc~encode_bits proc~b64_encode_r4->proc~encode_bits proc~b64_encode_i4->proc~encode_bits proc~b64_encode_i2->proc~encode_bits proc~b64_encode_i1->proc~encode_bits proc~b64_encode_string->proc~encode_bits proc~b64_encode_string->interface~byte_size proc~byte_size_i1p byte_size_I1P interface~byte_size->proc~byte_size_i1p proc~byte_size_r4p byte_size_R4P interface~byte_size->proc~byte_size_r4p proc~byte_size_i4p byte_size_I4P interface~byte_size->proc~byte_size_i4p proc~byte_size_i8p byte_size_I8P interface~byte_size->proc~byte_size_i8p 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_chr byte_size_chr interface~byte_size->proc~byte_size_chr

Contents

Source Code


Source Code

   elemental function encode(self, codec) result(encoded)
   !< Return a string encoded accordingly the codec.
   !<
   !< @note Only BASE64 codec is currently available.
   !<
   !<```fortran
   !< type(string) :: astring
   !< astring = 'How are you?'
   !< print '(L1)', astring%encode(codec='base64')//''=='SG93IGFyZSB5b3U/'
   !<```
   !=> T <<<
   class(string),             intent(in) :: self    !< The string.
   character(kind=CK, len=*), intent(in) :: codec   !< Encoding codec.
   type(string)                          :: encoded !< Encoded string.

   if (allocated(self%raw)) then
     encoded = codec
     select case(encoded%upper()//'')
     case('BASE64')
       call b64_encode(s=self%raw, code=encoded%raw)
     endselect
   endif
   endfunction encode