Return a string decoded accordingly the codec.
Only BASE64 codec is currently available.
```fortran type(string) :: astring astring = 'SG93IGFyZSB5b3U/' print '(A)', astring%decode(codec='base64')//'' ! print "How are you?"
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(string), | intent(in) | :: | self | The string. |
||
| character(kind=CK,len=*), | intent(in) | :: | codec | Encoding codec. |
Decoded string.
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.
elemental function decode(self, codec) result(decoded)
!---------------------------------------------------------------------------------------------------------------------------------
!< Return a string decoded accordingly the codec.
!<
!< @note Only BASE64 codec is currently available.
!<
!<### Example
!<
!<```fortran
!< type(string) :: astring
!< astring = 'SG93IGFyZSB5b3U/'
!< print '(A)', astring%decode(codec='base64')//'' ! print "How are you?"
!---------------------------------------------------------------------------------------------------------------------------------
class(string), intent(in) :: self !< The string.
character(kind=CK, len=*), intent(in) :: codec !< Encoding codec.
type(string) :: decoded !< Decoded string.
type(string) :: codec_u !< Encoding codec in upper case string.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
if (allocated(self%raw)) then
decoded = self
codec_u = codec
select case(codec_u%upper()//'')
case('BASE64')
call b64_decode(code=self%raw, s=decoded%raw)
endselect
decoded = decoded%strip(remove_nulls=.true.)
endif
return
!---------------------------------------------------------------------------------------------------------------------------------
endfunction decode