This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

freopen() with "ccs=<charset>" in the mode


Hello,

How is freopen() supposed to work with "ccs=<charset>" in the mode?

  #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
  }

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.

Thanks,

                Ilya


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]