Manual Reference Pages  - upper (3m_unicode)

NAME

UPPER(3f) - [M_unicode:CASE] changes a string to uppercase (LICENSE:MIT)

CONTENTS

Synopsis
Description
Options
Returns
Trivia
Examples
Author
License

SYNOPSIS

pure elemental function upper(str) result (string)

     character(*), intent(in)    :: str
     character(len(str))         :: string  ! output string

DESCRIPTION

upper(string) returns a copy of the input string with all characters converted to uppercase, assuming Unicode character sets are being used.

OPTIONS

str string to convert to uppercase

RETURNS

upper copy of the input string with all characters converted to uppercase.

TRIVIA

The terms "uppercase" and "lowercase" date back to the early days of the mechanical printing press. Individual metal alloy casts of each needed letter, or punctuation symbol, were meticulously added to a press block, by hand, before rolling out copies of a page. These metal casts were stored and organized in wooden cases. The more often needed miniscule letters were placed closer to hand, in the lower cases of the work bench. The less often needed, capitalized, majuscule letters, ended up in the harder to reach upper cases.

EXAMPLES

Sample program:

   program demo_upper
   use iso_fortran_env, only : stdout => output_unit
   use M_unicode,       only : upper, unicode_type, assignment(=)
   use M_unicode,       only : ut => unicode_type, operator(==)
   implicit none
   character(len=*),parameter :: g=’(*(g0))’
   type(unicode_type)         :: pangram
   type(unicode_type)         :: diacritics
   type(unicode_type)         :: expected
      !
      ! a sentence containing every letter of the English alphabet
      ! often used to test telegraphs since the advent of the 19th century
      ! and as an exercise repetitively generated in typing classes
      pangram  = "The quick brown fox jumps over the lazy dog."
      expected = "THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG."
      call test(pangram,expected)
      !
      ! Slovak pangram
      pangram    = ’Vypätá dcéra grófa Maxwella s IQ nižším ako &
      &kôň núti čeľaď hrýzť hŕbu jabĺk.’
      expected   = ’VYPÄTÁ DCÉRA GRÓFA MAXWELLA S IQ NIŽŠÍM AKO &
      &KÔŇ NÚTI ČEĽAĎ HRÝZŤ HŔBU JABĹK.’
      call test(pangram,expected)
      !
      ! contains each special Czech letter with diacritics exactly once
      print g,’("A horse that was too yellow-ish moaned devilish odes")’
      diacritics = ’Příliš žluťoučký kůň úpěl ďábelské ódy.’
      expected   = ’PŘÍLIŠ ŽLUŤOUČKÝ KŮŇ ÚPĚL ĎÁBELSKÉ ÓDY.’
      call test(diacritics,expected)
   contains
   subroutine test(in,expected)
   type(unicode_type),intent(in) :: in
   type(unicode_type),intent(in) :: expected
   type(unicode_type)            :: uppercase
   character(len=*),parameter    :: nl=new_line(’A’)
      write(stdout,g)in%character()
      uppercase=upper(in)
      write(stdout,g)uppercase%character()
      write(stdout,g)merge(’PASSED’,’FAILED’,uppercase == expected ),nl
   end subroutine test
   end program demo_upper

Expected output

  > The quick brown fox jumps over the lazy dog.
  > THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG.
  > PASSED
  >
  > Vypätá dcéra grófa Maxwella s IQ nižším ako kôň núti ...
  > čeľaď hrýzť hŕbu jabĺk.
  > VYPÄTÁ DCÉRA GRÓFA MAXWELLA S IQ NIŽŠÍM AKO KÔŇ NÚTI ...
  > ČEĽAĎ HRÝZŤ HŔBU JABĹK.
  > PASSED
  >
  > ("A horse that was too yellow-ish moaned devilish odes")
  > Příliš žluťoučký kůň úpěl ďábelské ódy.
  > PŘÍLIŠ ŽLUŤOUČKÝ KŮŇ ÚPĚL ĎÁBELSKÉ ÓDY.
  > PASSED

AUTHOR

John S. Urban

LICENSE

    MIT