Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | James Kuyper <jameskuyper@verizon.net> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: No fread and fwrite for wide characters? |
| Date | 2011-11-10 12:34 -0500 |
| Organization | A noiseless patient Spider |
| Message-ID | <4EBC0B3D.5040504@verizon.net> (permalink) |
| References | <j9h1ff$odc$1@oravannahka.helsinki.fi> |
On 11/10/2011 12:26 PM, Lauri Alanko wrote: > It seems that the standard I/O operations for wide characters are > conspicuously lacking functions that read or write an array of > arbitrary wide characters into a stream. E.g. for writing, there's > only fputws, which writes a L'\0'-terminated string, not including the > terminator. So if there's a buffer that may contain L'\0', one has to > iterate it using fputwc, maybe with the assistance of fputws if an > exact count of successfully written characters is not needed. > > The workaround is not a big deal, but this seems like a strange > omission, since otherwise there are wide I/O counterparts for all > basic byte I/O operations. Granted, mixing text and null characters is > not very common, but it does happen, e.g. when null characters are > used as field separators. > > So does anyone have an idea why "fwwrite" and "fwread" are missing? I'm not sure exactly what behavior you want fwwrite() to have. Here's how the standard describes fwrite(): > 7.19.8.2 The fwrite function > Synopsis > #include <stdio.h> > size_t fwrite(const void * restrict ptr, > size_t size, size_t nmemb, > FILE * restrict stream); > > Description > The fwrite function writes, from the array pointed to by ptr, up to nmemb elements > whose size is specified by size, to the stream pointed to by stream. For each object, > size calls are made to the fputc function, taking the values (in order) from an array of > unsigned char exactly overlaying the object. The file position indicator for the > stream (if defined) is advanced by the number of characters successfully written. If an > error occurs, the resulting value of the file position indicator for the stream is > indeterminate. > > Returns > The fwrite function returns the number of elements successfully written, which will be > less than nmemb only if a write error is encountered. If size or nmemb is zero, > fwrite returns zero and the state of the stream remains unchanged. Could you modify that description so that it describes what you want for fwwrite()?
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
No fread and fwrite for wide characters? Lauri Alanko <la@iki.fi> - 2011-11-10 17:26 +0000
Re: No fread and fwrite for wide characters? James Kuyper <jameskuyper@verizon.net> - 2011-11-10 12:34 -0500
Re: No fread and fwrite for wide characters? Lauri Alanko <la@iki.fi> - 2011-11-10 17:58 +0000
Re: No fread and fwrite for wide characters? James Kuyper <jameskuyper@verizon.net> - 2011-11-10 13:38 -0500
Re: No fread and fwrite for wide characters? Lauri Alanko <la@iki.fi> - 2011-11-10 23:23 +0000
Re: No fread and fwrite for wide characters? Harald van Dijk <truedfx@gmail.com> - 2011-11-11 09:33 -0800
Re: No fread and fwrite for wide characters? Lauri Alanko <la@iki.fi> - 2011-11-12 00:09 +0000
Re: No fread and fwrite for wide characters? Phil Carmody <thefatphil_demunged@yahoo.co.uk> - 2011-11-12 00:28 +0200
Re: No fread and fwrite for wide characters? Ike Naar <ike@sverige.freeshell.org> - 2011-11-11 22:58 +0000
Re: No fread and fwrite for wide characters? Phil Carmody <thefatphil_demunged@yahoo.co.uk> - 2011-11-12 14:07 +0200
Re: No fread and fwrite for wide characters? James Kuyper <jameskuyper@verizon.net> - 2011-11-11 18:00 -0500
csiph-web