[Bug libfortran/52539] I/O: Wrong result for UTF-8/UCS-4 list-directed and namelist read and nml write

jvdelisle at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Mar 28 23:50:00 GMT 2014


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52539

--- Comment #6 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
Patch part 1:

Index: write.c
===================================================================
--- write.c    (revision 208887)
+++ write.c    (working copy)
@@ -1835,7 +1835,10 @@
               break;

         case BT_CHARACTER:
-          write_character (dtp, p, 1, obj->string_length, DELIM);
+          if (dtp->u.p.current_unit->flags.encoding == ENCODING_UTF8)
+        write_character (dtp, p, 4, obj->string_length, DELIM);
+          else
+        write_character (dtp, p, 1, obj->string_length, DELIM);
               break;

         case BT_REAL:

Results:

 Write to terminal just the strings:
>a你好<
 >a你好<
 Write to the terminal the namelist:
&NML
 STR="a你好",
 /


More information about the Gcc-bugs mailing list