C Library Functions  - percent_encode (3)

NAME

percent_encode(3f) - [M_strings:ENCODE] percent-encode strings and character arrays (LICENSE:PD)

CONTENTS

Synopsis
Description
Options
Returns
Examples
Author

SYNOPSIS

function percent_encode(text)

     character(len=1),intent(in)  :: text(:)
     character(len=;),allocatable :: percent_encode

or

function percent_encode(text)

     character(len=*),intent(in)  :: text
     character(len=;),allocatable :: percent_encode

DESCRIPTION

This function percent-encodes ASCII strings or ASCII character arrays. "Reserved" characters are encoded.

URI containing spaces or most other non-alphanumeric characters must be encoded using percent encoding (aka. URL encoding).

The characters allowed in a URI are either reserved or unreserved (or a percent character as part of a percent-encoding). Reserved characters are those characters that sometimes have special meaning, while unreserved characters have no such meaning. Using percent-encoding, characters which otherwise would not be allowed are represented using allowed characters. The sets of reserved and unreserved characters and the circumstances under which certain reserved characters have special meaning have changed slightly with each revision of specifications that govern URIs and URI schemes.

According to RFC 3986, the characters in a URL have to be taken from a defined set of unreserved and reserved ASCII characters. Any other characters are not allowed in a URL.

The unreserved characters can be encoded, but should not be. The unreserved characters are:

      > ABCDEFGHIJKLMNOPQRSTUVWXYZ
      > abcdefghijklmnopqrstuvwxyz
      > 0123456789-_.~

The reserved characters have to be encoded only under certain circumstances. The reserved characters are:

      >  * ’ ( ) ; : @ & = + $ , / ? % # [ ]

OPTIONS

SOURCE_STRING
  string or character array to encode

RETURNS

percent_encode
  a string holding a percent-encoded copy of the input

EXAMPLES

Sample program:

   program demo_percent_encode
   use M_strings, only : percent_encode
   use, intrinsic :: iso_fortran_env, only : stdout=>output_unit
   implicit none
      write(*,*)percent_encode(’[this is a string]’)
   end program demo_percent_encode

Results:

 >  %5Bthis%20is%20a%20string%5D

AUTHOR

John S. Urban


Nemo Release 3.1 percent_encode (3) July 22, 2023
Generated by manServer 1.08 from f1e0b35c-7d35-4f53-b6c9-1e0b0b196b85 using man macros.