public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* freopen() with "ccs=<charset>" in the mode
@ 2018-09-16  8:05 Ilya Dryomov
  2018-09-17 12:10 ` Florian Weimer
  0 siblings, 1 reply; 3+ messages in thread
From: Ilya Dryomov @ 2018-09-16  8:05 UTC (permalink / raw)
  To: libc-alpha

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: freopen() with "ccs=<charset>" in the mode
  2018-09-16  8:05 freopen() with "ccs=<charset>" in the mode Ilya Dryomov
@ 2018-09-17 12:10 ` Florian Weimer
  2018-09-17 13:20   ` Ilya Dryomov
  0 siblings, 1 reply; 3+ messages in thread
From: Florian Weimer @ 2018-09-17 12:10 UTC (permalink / raw)
  To: Ilya Dryomov, libc-alpha

On 09/16/2018 10:05 AM, Ilya Dryomov wrote:
> 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.

This looks like a bug.  Would you please file a bug in Bugzilla so that 
this is not lost?

Thanks,
Florian

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: freopen() with "ccs=<charset>" in the mode
  2018-09-17 12:10 ` Florian Weimer
@ 2018-09-17 13:20   ` Ilya Dryomov
  0 siblings, 0 replies; 3+ messages in thread
From: Ilya Dryomov @ 2018-09-17 13:20 UTC (permalink / raw)
  To: fweimer; +Cc: libc-alpha

On Mon, Sep 17, 2018 at 2:10 PM Florian Weimer <fweimer@redhat.com> wrote:
>
> On 09/16/2018 10:05 AM, Ilya Dryomov wrote:
> > 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.
>
> This looks like a bug.  Would you please file a bug in Bugzilla so that
> this is not lost?

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

Thanks,

                Ilya

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-09-17 13:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-16  8:05 freopen() with "ccs=<charset>" in the mode Ilya Dryomov
2018-09-17 12:10 ` Florian Weimer
2018-09-17 13:20   ` Ilya Dryomov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).