This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: gcc4[1.7] printf treats differently a string constant and a character array


> Some comments:
> 1- I think that printf(string_constant) and printf(char_array) should give
> the same
> output in any circumstance.
> 2- In absence of a call to setlocale printf((string_constant) writes
> according to
> the locale of the environment, but Âprintf(char_array) Âdoes not, even
> though Âit is
> Âaffected by the locale of the environment.

No, both work according to the "C" locale, with its UTF-8 character
set, and behaviour for invalid UTF-8 sequences is undefined for both.
"Undefined" means anything might happen, including inconsistent
behaviour. (Requiring consistent behaviour would make the puts
optimisation impossible.)

> 3- I think that a program that was written for locale=C should work without
> modification
> if the locale in the environment is any of the one-byte characters ones.
> 4- I think that a plain C (8-bit transparent) locale should be available,
> even if it
> is not the default one.

If you don't call setlocale, all you can expect according to the C and
POSIX standards is the so-called portable character set. So you
shouldn't assume that the C locale is 8-bit transparent.

However, since that is a valid assumption on Linux and others, Cygwin
might indeed be better off following their example. There's a
discussion about that on cygwin-developers.

Andy

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]