http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52539
Bug #: 52539
Summary: I/O: Wrong result for UTF-8/UCS-4 list-directed and
namelist read and nml write
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: libfortran
AssignedTo: [email protected]
ReportedBy: [email protected]
CC: [email protected]
Example using UTF-8 string with UCS-4 character variables; the string contains
(a)(ni)(hao)(b) ("a你好").
The following program prints here the following. One sees that list-directed
writing correctly works but namelist writing doesn't. (Also the fort.99
contains the correct string.)
For reading, neither list-directed reading nor namelist reading works.
Looking at list_read.c, UTF-8 seems to be unhandled. (And in nml_get_obj_data,
the "array_loop_spec ind" initialization won't survive the array descriptor
reform unmodified.)
>a你好< ! << OK
>a你好< ! << OK
&NML
STR="a", ! << WRONG
/
>�����XX< ! << WRONG
>�����XX< ! << WRONG
&NML
STR="a��", ! << WRONG
/
>aä½< ! << WRONG
>aä½< ! << WRONG
character(len=3, kind=4) :: str, str2
namelist /nml/ str
str = 4_'a'//char (int (z'4F60'),4) &
//char (int (z'597D'), 4)//4_'b'
open(6, encoding='utf-8')
write(*, '(a)') 4_'>'//str//4_'<'
write(*, *) 4_'>'//str//4_'<'
write(*,nml=nml)
open(99, encoding='utf-8',form='formatted')
write(99, '(3a)') '&nml str = "', str, '" /'
write(99, '(a)') str
rewind(99)
str = 4_'XXXX'
str2 = 4_'YYYY'
read(99,nml=nml)
read(99, *) str2
close(99, status='delete')
write(*, '(a)') 4_'>'//str//4_'<'
write(*, *) 4_'>'//str//4_'<'
write(*,nml=nml)
write(*, *) 4_'>'//str2//4_'<'
write(*, '(a)') 4_'>'//str2//4_'<'
end