[GRASS-dev] Re: [GRASS-stats] Sys.setlocale for GRASS6.4

Glynn Clements glynn at gclements.plus.com
Sat Sep 5 14:55:24 EDT 2009


Markus Neteler wrote:

> >> @grass-dev: There are encoding issues with --interface-description
> >>    which states UTF-8 also then the actual language encoding is different:
> 
> [then -> when]
> 
> ...
> > The --interface description option needs to either determine the
> > locale's encoding via e.g. nl_langinfo() and use that in the header,
> 
> It seems to be already there?
> 
> lib/gis/parser.c:
> 
> static void G_usage_xml(void)
> {
> ...
> #if defined(HAVE_LANGINFO_H)
>     encoding = nl_langinfo(CODESET);
>     if (!encoding || strlen(encoding) == 0) {
>         encoding = "UTF-8";
>     }

That would explain the sense of déjà vu ;)

> Apparently the Windows built was missing HAVE_LANGINFO_H or it
> isn't properly set on Windows.

This probably won't exist on Windows. I think that we can get the
information from locale_charset(), declared in localcharset.h and
defined in both libintl and libgettext.

Can someone try the attached patch?

-- 
Glynn Clements <glynn at gclements.plus.com>

-------------- next part --------------
Index: lib/gis/parser.c
===================================================================
--- lib/gis/parser.c	(revision 39007)
+++ lib/gis/parser.c	(working copy)
@@ -77,6 +77,9 @@
 #if defined(HAVE_LANGINFO_H)
 #include <langinfo.h>
 #endif
+#if defined(__MINGW32__) && defined(USE_NLS)
+#include <localcharset.h>
+#endif
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -1311,6 +1314,11 @@
     if (!encoding || strlen(encoding) == 0) {
 	encoding = "UTF-8";
     }
+#elif defined(__MINGW32__) && defined(USE_NLS)
+    encoding = locale_charset();
+    if (!encoding || strlen(encoding) == 0) {
+	encoding = "UTF-8";
+    }
 #else
     encoding = "UTF-8";
 #endif


More information about the grass-stats mailing list