This is the mail archive of the
mailing list for the glibc project.
freopen() with "ccs=<charset>" in the mode
- From: Ilya Dryomov <idryomov at gmail dot com>
- To: libc-alpha at sourceware dot org
- Date: Sun, 16 Sep 2018 10:05:30 +0200
- Subject: freopen() with "ccs=<charset>" in the mode
How is freopen() supposed to work with "ccs=<charset>" in the mode?
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:
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.