Manual Reference Pages  - expand_html (3m_unicode)

NAME

expand_html(3f) - [M_unicode:ENCODE] expand HTML character entities ("&NAME;" strings) (LICENSE:MIT)

CONTENTS

Synopsis
Description
Options
Returns
Examples
Author
License

SYNOPSIS

pure elemental function expand_html(str) result (string)

     type(unicode_type),intent(in),optional :: str
     !  or
     character(len=*),intent(in),optional   :: str

type(unicode_type) :: string

DESCRIPTION

expand_html(string) returns a copy of the input string with all HTML character entities ( "&NAME;" and "&#NUMBER;") expanded

OPTIONS

str string containing HTML character entities to expand.
           If STR is not present a table of all the HTML character entity
           names and the characer they represent and its decimal and
           hexadecimal value(s) is written to stdout

RETURNS

expand_html
  copy of the input string with all HTML character entities expanded

EXAMPLES

Sample program:

   program demo_expand_html
   use iso_fortran_env, only : stdout => output_unit
   use M_unicode,       only : expand_html, unicode_type, assignment(=)
   use M_unicode,       only : ut => unicode_type, operator(==)
   use M_unicode,       only : ch => character
   implicit none
   character(len=*),parameter :: g=’(*(g0))’
   integer                    :: i
   character(len=*),parameter :: data(*)=[character(len=132) :: &
   ’             HTML Character Entity Test Page’, &
   ’   Description     Entity  Entity  Rendered ’, &
   ’                   Name    Number  Result’, &
   ’Less than          &lt;    &#60;   <<<’, &
   ’Greater than       &gt;    &#62;   >>>’, &
   ’Ampersand          &amp;   &#38;   &&&’, &
   ’Copyright          &copy;  &#169;  ©©©’, &
   ’Registered         &reg;   &#174;  ®®®’, &
   ’Trademark          &trade; &#8482; ™™™’, &
   ’Euro               &euro;  &#8364; €€€’, &
   ’Pound              &pound; &#163;  £££’, &
   ’Non-breaking space &nbsp;  &#160;  Before   After’]
      do i=1,size(data)
         write(stdout,g)trim(ch(expand_html(data(i))))
      enddo
   end program demo_expand_html

Expected output

  >              HTML Character Entity Test Page
  >    Description     Entity  Entity  Rendered
  >                    Name    Number  Result
  > Less than          <    <   <<<
  > Greater than       >    >   >>>
  > Ampersand          &   &   &&&
  > Copyright          ©  ©  ©©©
  > Registered         ®   ®  ®®®
  > Trademark          ™ ™ ™™™
  > Euro               €  € €€€
  > Pound              £ £  £££
  > Non-breaking space       Before   After

AUTHOR

John S. Urban

LICENSE

    MIT