| 1 |
! { dg-do run } |
| 2 |
! PR118571 UTF-8 output and the A edit descriptor. |
| 3 |
|
| 4 |
program test |
| 5 |
|
| 6 |
use iso_fortran_env |
| 7 |
|
| 8 |
implicit none |
| 9 |
|
| 10 |
integer, parameter :: ucs4 = selected_char_kind('ISO_10646') |
| 11 |
|
| 12 |
character(kind=ucs4, len=1), parameter :: alpha = char(int(z'03B1'), ucs4) |
| 13 |
character(kind=ucs4, len=1), parameter :: beta = char(int(z'03B2'), ucs4) |
| 14 |
character(kind=ucs4, len=1), parameter :: space = ucs4_' ' |
| 15 |
|
| 16 |
integer fd |
| 17 |
character(kind=ucs4,len=:), allocatable :: str |
| 18 |
character(kind=ucs4,len=25) :: instr, correct |
| 19 |
|
| 20 |
fd = 42 |
| 21 |
|
| 22 |
open (fd, encoding='UTF-8', status="scratch") |
| 23 |
open (output_unit, encoding='UTF-8') |
| 24 |
str = repeat(space,6)//alpha//beta//alpha//beta |
| 25 |
|
| 26 |
write(fd,'(I4,1X,A)') len_trim(str), str |
| 27 |
rewind(fd) |
| 28 |
read(fd,'(a)') instr |
| 29 |
if (trim(instr) /= ucs4_' 10 '//trim(str)) stop 1 |
| 30 |
|
| 31 |
str = alpha // beta // alpha // beta |
| 32 |
rewind(fd) |
| 33 |
write(fd,'(I4,1X,">",A,"<")') len_trim(str(1:1)), str(1:1) |
| 34 |
rewind(fd) |
| 35 |
read(fd,'(a)') instr |
| 36 |
if (trim(instr) /= ucs4_' 1 >'//alpha//ucs4_'<') stop 2 |
| 37 |
|
| 38 |
rewind(fd) |
| 39 |
write(fd,*) len_trim(str(1:1)), str(1:1) |
| 40 |
rewind(fd) |
| 41 |
read(fd,'(a)') instr |
| 42 |
if (trim(instr) /= ucs4_' 1 '//alpha) stop 3 |
| 43 |
|
| 44 |
rewind(fd) |
| 45 |
write(fd,'(I4,1X,">",A1,"<")') len_trim(str(1:1)), str(1:1) |
| 46 |
rewind(fd) |
| 47 |
read(fd, '(a)') instr |
| 48 |
if (trim(instr) /= ucs4_' 1 >'//alpha//ucs4_'<') stop 4 |
| 49 |
|
| 50 |
rewind(fd) |
| 51 |
write(fd,'(I4,1X,">",A1,"<")') len_trim(str), str |
| 52 |
rewind(fd) |
| 53 |
read(fd, '(a)') instr |
| 54 |
if (trim(instr) /= ucs4_' 4 >'//alpha//ucs4_'<') stop 5 |
| 55 |
close(fd) |
| 56 |
end program |
| 57 |
|