Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #13037

Re: No fread and fwrite for wide characters?

From James Kuyper <jameskuyper@verizon.net>
Newsgroups comp.lang.c
Subject Re: No fread and fwrite for wide characters?
Date 2011-11-10 13:38 -0500
Organization A noiseless patient Spider
Message-ID <4EBC1A22.5090407@verizon.net> (permalink)
References <j9h1ff$odc$1@oravannahka.helsinki.fi> <4EBC0B3D.5040504@verizon.net> <j9h3bu$p8k$1@oravannahka.helsinki.fi>

Show all headers | View raw


On 11/10/2011 12:58 PM, Lauri Alanko wrote:
> In article <4EBC0B3D.5040504@verizon.net>,
> James Kuyper  <jameskuyper@verizon.net> wrote:
>> Could you modify that description so that it describes what you want for
>> fwwrite()?
> 
> Not really, since the "element" concept of fwrite is not applicable to
> wide characters (and even in general it's mostly a useless historical
> remnant).

In most of my fwrite() calls, either the element size is 1 or the number
of elements is one; but for about 10% of my fwrite() calls, the
"element" concept is alive and well.

> ... But I'll do better, and provide a reference implementation:
> 
> size_t fwwrite(FILE* file, const wchar_t* wcs, size_t size)
> {
> 	for (size_t n = 0; n < size; n++) {
> 		if (fputwc(wcs[n], file) == WEOF) {
> 			return n;
> 		}
> 	}
> 	return size;
> }

So, this is not at all the wide character equivalent of fwrite(), which
makes more sense, since narrow characters have nothing to do fwrite().
So this really deserves some other name, one which doesn't imply a
non-existent parallel to fwrite().

Which narrow-character function did you consider this to be closest to?
It's similar to fputs(), except for the count, but there's already an
fputws(), which is an exact parallel to fputs().

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


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