Using Unicode Characters in Fortran

Hello,

It compiles with older versions of GNU Fortran, ie with 7.4.0:

I don’t know why it now fails with newer versions of gfortran.

Regards,
Ev. Drikos

Hi @drikosev

This link worked in newer version

Regards
Apurva

Thanks. Here is an updated version of the example, accepted also by gfortran-13:

program test
    use iso_fortran_env
    implicit none
    
    integer,parameter :: CK = selected_char_kind('ISO_10646')

    !see also https://en.wikipedia.org/wiki/Combining_Diacritical_Marks
    !see also https://www.compart.com/en/unicode/U+006F
    character(kind=CK,len=7) :: s = CHAR(INT(Z'0061'), KIND=CK) //& !a
                                  & CHAR(INT(Z'0310'), KIND=CK) //& !◌̐ -> a̐
                                ! & CHAR(INT(Z'00E9'), KIND=CK) //& !é (precomposed)
                                  & CHAR(INT(Z'0065'), KIND=CK) //& !e (decomposed)
                                  & CHAR(INT(Z'0301'), KIND=CK) //& !◌́
                                ! & CHAR(INT(Z'00F6'), KIND=CK) //& !ö  (precomposed)
                                  & CHAR(INT(Z'006F'), KIND=CK) //& !o (decomposed)
                                  & CHAR(INT(Z'0308'), KIND=CK) //& !Combining Diaeresis
                                  & CHAR(INT(Z'0332'), KIND=CK)     !Combining Low Line
    
    open(output_unit,encoding='utf-8')
    
    write(output_unit,*) s
    write(output_unit,*) 'len(s) = ', len(s)
    write(output_unit,*) 's(1:1) = ', s(1:1)
    
end program test


Hello,

Just for the record, GNU Fortran supports the command line option ‘-fallow-invalid-boz’ (default) and past versions, ie 7, as already said above, were intentionally accepting BOZ literals in places that shouldn’t. I’m not aware when support for the particular extension was dropped.

Regards,
Ev. Drikos

@drikosev Thanks for your help. This is working in gfortran-13