[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: nl_langinfo and localized day/month names
From: |
Eli Zaretskii |
Subject: |
Re: nl_langinfo and localized day/month names |
Date: |
Sun, 06 Jul 2014 17:28:35 +0300 |
> Date: Sat, 05 Jul 2014 14:59:05 -0700
> From: Paul Eggert <address@hidden>
> CC: address@hidden
>
> Revised proposed patch attached.
Thanks. I needed the follow-up patch below to be able to build Guile
and run all the tests successfully. I hope the comments within the
patch explain why those changes are needed on MS-Windows.
Otherwise, the version you sent works fine for me. Thanks.
--- lib/nl_langinfo.c~4 2014-07-06 07:49:28 +0300
+++ lib/nl_langinfo.c 2014-07-06 17:17:23 +0300
@@ -145,24 +145,41 @@ nl_langinfo (nl_item item)
{
/* nl_langinfo items of the LC_CTYPE category */
case CODESET:
+# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+ {
+ char *codeset = ctype_codeset ();
+
+ if (*codeset)
+ {
+ /* On MS-Windows, ctype_codeset returns the number of the
+ codepage, as a string. We need to prepend the "CP"
+ prefix to make it a valid codeset name. */
+ sprintf (nlbuf, "CP%s", codeset);
+ }
+ else
+ {
+ /* The Windows API has a function returning the locale's
+ codepage as a number, but the value doesn't change
+ according to what the 'setlocale' call specified. So
+ use it as a last resort, in case the string returned by
+ 'setlocale' doesn't specify the codepage. */
+ sprintf (nlbuf, "CP%u", GetACP ());
+ }
+ return nlbuf;
+ }
+# else /* !MS-Windows */
{
char *codeset = ctype_codeset ();
+
if (*codeset)
return codeset;
}
-# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
- /* The Windows API has a function returning the locale's
- codepage as a number, but the value doesn't change according
- to what the 'setlocale' call specified. So use it as a
- last resort, in case the string returned by 'setlocale'
- doesn't specify the codepage. */
- sprintf (nlbuf, "CP%u", GetACP ());
- return nlbuf;
-# elif defined __BEOS__
+# if defined __BEOS__
return "UTF-8";
-# else
+# else
return "ISO-8859-1";
-# endif
+# endif
+# endif /* !MS-Windows */
/* nl_langinfo items of the LC_NUMERIC category */
case RADIXCHAR:
return localeconv () ->decimal_point;