Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Delivered-To: mailing list cygwin@cygwin.com Message-ID: <3FD3502C.2020600@terra.com.br> Date: Sun, 07 Dec 2003 13:07:08 -0300 From: =?ISO-8859-1?Q?Marcelo_Rezende_M=F3dolo?= User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.5) Gecko/20031007 X-Accept-Language: pt-br, en-us, en MIME-Version: 1.0 To: cygwin@cygwin.com Subject: LOCALE ERROR Content-Type: multipart/mixed; boundary="------------090801060501060908050005" --------------090801060501060908050005 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hi, I have a program that needs the locale support, so I include 'locale.h'. I make the program but the output was wrong. With the cygwin library the setlocale function do not work, but if I link with mingw library it is ok I am sending a sample program that demonstrate the error. Linking with CYGWIN: marcelo@est01 /usr/src/testes/locale/msdn $ gcc -o crt_locale crt_locale.c marcelo@est01 /usr/src/testes/locale/msdn $ $ ./crt_locale.exe In German locale, strftime returns 'x' No Brasil locale, strftime retorna 'x' In 'C' locale, strftime returns 'x' marcelo@est01 /usr/src/testes/locale/msdn $ Linking with MINGW (-mno-cygwin) marcelo@est01 /usr/src/testes/locale/msdn $ gcc -mno-cygwin -o crt_locale crt_locale.c marcelo@est01 /usr/src/testes/locale/msdn $ $ ./crt_locale.exe In German locale, strftime returns 'Sonntag, 07. Dezember 2003' No Brasil locale, strftime retorna 'domingo, 07 de dezembro de 2003' In 'C' locale, strftime returns 'Sunday, December 07, 2003' marcelo@est01 /usr/src/testes/locale/msdn $ Thanks, Marcelo Modolo --------------090801060501060908050005 Content-Type: text/plain; name="crt_locale.c" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="crt_locale.c" // crt_locale.c /* Sets the current locale to "Germany" using the * setlocale function and demonstrates its effect on the strftime * function. */ #include #include #include int main(void) { time_t ltime; struct tm *thetime; unsigned char str[100]; setlocale(LC_ALL, "German"); time (<ime); thetime = gmtime(<ime); /* %#x is the long date representation, appropriate to * the current locale */ if (!strftime((char *)str, 100, "%#x", (const struct tm *)thetime)) printf("strftime failed!\n"); else printf("In German locale, strftime returns '%s'\n", str); /* portuguese-brazil */ setlocale(LC_ALL, "portuguese-brazil"); time (<ime); thetime = gmtime(<ime); /* %#x is the long date representation, appropriate to * the current locale */ if (!strftime((char *)str, 100, "%#x", (const struct tm *)thetime)) printf("strftime failed!\n"); else printf("No Brasil locale, strftime retorna '%s'\n", str); /* Set the locale back to the default environment */ setlocale(LC_ALL, "C"); time (<ime); thetime = gmtime(<ime); if (!strftime((char *)str, 100, "%#x", (const struct tm *)thetime)) printf("strftime failed!\n"); else printf("In 'C' locale, strftime returns '%s'\n", str); } --------------090801060501060908050005 Content-Type: text/plain; charset=us-ascii -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/ --------------090801060501060908050005--