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


Groups > comp.lang.c > #78215

Re: snprintf alternatives in iso9899

From Ben Bacarisse <ben.usenet@bsb.me.uk>
Newsgroups comp.lang.c
Subject Re: snprintf alternatives in iso9899
Date 2015-12-09 02:16 +0000
Organization A noiseless patient Spider
Message-ID <87fuzc5pug.fsf@bsb.me.uk> (permalink)
References <n45p5d$hmp$1@speranza.aioe.org> <lnio48optn.fsf@kst-u.example.com> <n481m1$lpf$1@speranza.aioe.org> <dcpgguFo5q0U2@mid.individual.net>

Show all headers | View raw


Ian Collins <ian-news@hotmail.com> writes:

> Morten W. Petersen wrote:
>>
>> Ah yes.  Well I want to output the parsed XML on stdout, to aid
>> in the development and debugging process.
>>
>> I have been a bit confused by this whole console/stdout/encoding/
>> character type thing yes, and my thought initially was that it was
>> better to use the same function to output all kinds of strings, and
>> that converting something that is only ASCII characters to a wide char
>> and then printing it was better than mixing the (C) types of characters
>> that are sent to stdout.
>>
>> Have I understood it correctly when I say that to output what is UTF-32
>> internally, I need to break down each 32-bit character to a sequence
>> of 1-4 regular char and send those to stdout using for example putc,
>> if the encoding used in stdout is UTF-8?
>
> I guess that's what c32rtomb() is there for...

He's decided to limit himself to C90 so there is no c32rtomb.  But even
if only C99 were assumed he could just use printf with %lc and %ls
formats (provided wchar_t is also suitable).

To answer Morten: yes, in C90 you need to write your own code to output
the UTF-8 encoding of a character or a string.

-- 
Ben.

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


Thread

snprintf alternatives in iso9899 "Morten W. Petersen" <morphex@gmail.com> - 2015-12-08 06:18 +0100
  Re: snprintf alternatives in iso9899 Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-12-08 02:13 -0800
    Re: snprintf alternatives in iso9899 Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-12-08 10:38 +0000
  Re: snprintf alternatives in iso9899 Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-12-08 14:52 +0000
    Re: snprintf alternatives in iso9899 supercat@casperkitty.com - 2015-12-08 07:15 -0800
      Re: snprintf alternatives in iso9899 Tim Rentsch <txr@alumni.caltech.edu> - 2015-12-09 13:14 -0800
        Re: snprintf alternatives in iso9899 Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-12-09 16:28 -0500
          Re: snprintf alternatives in iso9899 Ian Collins <ian-news@hotmail.com> - 2015-12-10 10:35 +1300
            Re: snprintf alternatives in iso9899 Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-12-09 16:49 -0500
              Re: snprintf alternatives in iso9899 Ian Collins <ian-news@hotmail.com> - 2015-12-10 11:00 +1300
          Re: snprintf alternatives in iso9899 supercat@casperkitty.com - 2015-12-09 14:02 -0800
            Re: snprintf alternatives in iso9899 Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-12-10 02:41 -0800
          The FILE * pattern [was Re: snprintf alternatives in iso9899] Richard Heathfield <rjh@cpax.org.uk> - 2015-12-09 22:02 +0000
          Re: snprintf alternatives in iso9899 Keith Thompson <kst-u@mib.org> - 2015-12-09 14:49 -0800
    Re: snprintf alternatives in iso9899 Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-12-08 16:47 +0000
      Re: snprintf alternatives in iso9899 Keith Thompson <kst-u@mib.org> - 2015-12-08 09:18 -0800
      Re: snprintf alternatives in iso9899 Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-12-08 17:27 +0000
  Re: snprintf alternatives in iso9899 Keith Thompson <kst-u@mib.org> - 2015-12-08 08:41 -0800
    Re: snprintf alternatives in iso9899 "Morten W. Petersen" <morphex@gmail.com> - 2015-12-09 02:56 +0100
      Re: snprintf alternatives in iso9899 Ian Collins <ian-news@hotmail.com> - 2015-12-09 15:04 +1300
        Re: snprintf alternatives in iso9899 Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-12-09 02:16 +0000
      Re: snprintf alternatives in iso9899 Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-12-09 04:49 -0800
        Re: snprintf alternatives in iso9899 "Morten W. Petersen" <morphex@gmail.com> - 2015-12-10 08:00 +0100

csiph-web