Unicode

Unfortunately, even modern Fortran standards have no intrinsic support for Unicode I/O. To bypass this limitation, the Universal Coded Character Set defined in ISO 10646 can be used instead, which is mostly identical to UTF-32. Currently, ISO 10646 is not supported by Flang 5. The example below works with GNU Fortran only.

! unicode.f90
program main
    use, intrinsic :: 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')
    print '(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 argument, which is required for escaped Unicode characters. Otherwise, you have to do the type conversion manually:

string = u_'unicode_character: ' // char(int(z'2593'), u)

The binary must be executed in a terminal with Unicode support, like xterm or rxvt-unicode.