Unicode

Unfortunately, even modern Fortran has no intrinsic support for Unicode I/O. But the Universal Coded Character Set defined by ISO 10646 can be used instead, which is mostly identical to UTF-32. At the moment, ISO 10646 is not supported by Flang 5. The example below can be compiled with GNU Fortran only.

! unicode.f90
program main
    use iso_fortran_env
    implicit none
    integer,                  parameter   :: u = selected_char_kind('ISO_10646')
    character(kind=u, len=:), allocatable :: string

    string = u_'unicode character: \u2593'

    open(output_unit, encoding='utf-8')
    write (*, '(a)') string
end program main

Build the executable with:

$ gfortran7 -Wl,-rpath=/usr/local/lib/gcc7/ -fbackslash -o unicode unicode.f90

Please note the -fbackslash flag, which is needed for escaped Unicode characters. The binary must be executed in a terminal with Unicode support, like xterm or rxvt-unicode.