X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=-0.3 required=5.0 tests=AWL,BAYES_00,FH_DATE_PAST_20XX,SARE_MSGID_LONG40,SPF_PASS X-Spam-Check-By: sourceware.org MIME-Version: 1.0 In-Reply-To: <380-22009123301337494@cantv.net> References: <380-22009123301337494 AT cantv DOT net> Date: Fri, 1 Jan 2010 16:37:32 +0000 Message-ID: <416096c61001010837m39284257i3605e7261d21d257@mail.gmail.com> Subject: Re: gcc4[1.7] printf treats differently a string constant and a character array From: Andy Koppe To: rodmedina AT cantv DOT net, cygwin AT cygwin DOT com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com > 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 =C2=A0printf(char_array) =C2=A0does no= t, even > though =C2=A0it is > =C2=A0affected 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=3DC should work wit= hout > 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