Apply Excel LOOKUP in Fortran

Have had this cause problems many times when reading from text files. Is “123,456,789” one number or three? It depends. Is “123 456.789” one or two numbers? Maybe the decimal is actually the end of a sentence. And in handwritten documents middle-dot is popular; and Unicode
is allowing it to show up more easily, so do not leave out middle-dot as a separator… The underscore is perhaps the optimal separator (in ASCII character set, and has little meaning in other context (other than as a Fortran separator between kind and value !). Any character commonly appearing in prose (space, comma, period, …) causes all kinds of issues. Any character commonly associated with math operators is obviously off the table. Until everything uses Unicode nothing appears left to me in ASCII. Maybe we could all agree on a new convention where two commas are used. Given an unexpected consensus and a 1 000, years or 1,000 years (whichever comes first) that might work :smile:

middle_dot.f90
program testit
use iso_fortran_env, only : stdout=>output_unit
implicit none
integer                    :: i
integer,parameter          :: ascii = selected_char_kind ("ascii")
character,parameter        :: interpunct  = achar(183)
character(len=*),parameter :: document(*) = [character(len=80) :: &
 '<html><body><pre>      ',&
 'HTML Number   &#183;   ',&
 'HTML Hex      &#xB7;   ',&
 'HTML Entity   &middot; ',&
 '</pre></body></html>   ']
   ! NOTE: except for a terminal, mixing iso-8859 and ucs4 in the same file is a bad idea

   ! Default set usually is extended ASCII with a middle dot at ADE 183
   open (stdout, encoding='default')

   write(stdout,'(*(g0))')1,2,interpunct,ascii_'000',interpunct,0,0,0
   ! writing an HTML file using ASCII characters and viewing with a browser works well.
   write(stdout,'(a)') (trim(document(i)),i=1,size(document))
   ! browsers like lynx(1) let you see the file in a terminal window:
   !     a.out|lynx -dump -stdin
block
! If UCS4 is supported
integer,parameter                      :: ucs4 = selected_char_kind("ISO_10646")
character(kind=ucs4, len=1),parameter  :: middle_dot  = char(int(z'B7'), ucs4)
character(len=:,kind=ucs4),allocatable :: str
   open (stdout, encoding='UTF-8')
   str = ucs4_'10' //middle_dot// ucs4_'000'
   write (stdout,'(*(g0))') str
endblock
end program testit

I have already spent too much time explaining why code reading a number is ignoring underscores
and spaces and sometimes commas and that middle dots are smaller and do not mean multiply.
to expect this to get resolved anytime soon. At least Fortran used to be consistent. Now that is changed as well.

As far as thinking that it must not be common because it took Fortran decades to allow it — there was no standard way to ask for date and time for around 30 or so years so that is not a good indicator to use :grimacing: At least they were sane enough to still not have added month and day names;

Maybe Fortran does point to a solution. Add a kind and quotes “1,000.5”_anglo.