Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: snprintf alternatives in iso9899 |
| Date | 2015-12-08 08:41 -0800 |
| Organization | None to speak of |
| Message-ID | <lnio48optn.fsf@kst-u.example.com> (permalink) |
| References | <n45p5d$hmp$1@speranza.aioe.org> |
"Morten W. Petersen" <morphex@gmail.com> writes:
> I'm wondering what the alternatives for snprintf are in ISO 9899, as
> it looks like C99 is the earliest standard that includes it.
ISO 9899 is the C standard. The current edition was published in 2011.
That edition supersedes the 1990 and 1999 editions.
I think you meant to ask about C90.
> What I'm trying to do, is print an ASCII string to the console, and
> I need to generate the entire string first, before I convert it to
> for example UTF-8 wide char. In other words, replace the printf
> things that are already in a program with something that can output
> Unicode.
C90 didn't have snprintf; that's why it was added to the language
in 1999. If you need to use snprintf, you can probably just go
ahead and use it. Most C implementations provide it, even if they
don't fully support C99.
If you can't use snprintf, you might be able to compute a maximum
size for the target array. sprintf doesn't check for a buffer
overrun but you can get away without that check if you're *very*
careful.
But I think you're a bit confused about UTF-8. There's no such
thing as a "UTF-8 wide char". UTF-8 is a representation of
Unicode that uses one to four octets for each Unicode code point.
ASCII is a 7-bit character set, usually represented using one
octet per character. ASCII text *is* UTF-8 text (that was a major
requirement for the design of UTF-8). If you have an ASCII string
that you want to print to the console, just print it.
You'll need to be more specific about what you're trying to do.
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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