[Bug stdio/23675] New: freopen() with "ccs=<charset>" leaves the stream unoriented

idryomov at gmail dot com sourceware-bugzilla@sourceware.org
Mon Sep 17 13:16:00 GMT 2018


https://sourceware.org/bugzilla/show_bug.cgi?id=23675

            Bug ID: 23675
           Summary: freopen() with "ccs=<charset>" leaves the stream
                    unoriented
           Product: glibc
           Version: unspecified
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: stdio
          Assignee: unassigned at sourceware dot org
          Reporter: idryomov at gmail dot com
  Target Milestone: ---

freopen() with "ccs=<charset>" leaves the stream unoriented:

  #include <assert.h>
  #include <stdio.h>
  #include <wchar.h>

  int main()
  {
          FILE *fp;

          fp = fopen("/tmp/foo", "w,ccs=UTF-16LE");
          assert(fwide(fp, 0) > 0); // ok
          fp = freopen(NULL, "w,ccs=UTF-16LE", fp);
          assert(fwide(fp, 0) > 0); // failure, fp is not oriented
  }

The man page explicitly lists freopen() alongside fopen():

  In addition to the above characters, fopen() and freopen() support
  the following syntax in mode:

      ,ccs=string

  The  given  string is taken as the name of a coded character set
  and the stream is marked as wide-oriented.

However freopen() appears to unconditionally put the stream into the
unoriented state.  When one of the wide functions is called sometime
later, the stream picks up the current locale -- the "ccs" parameter
is effectively ignored even though it is parsed.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the Glibc-bugs mailing list