OSDN Git Service

* fix locale charset on Windows.
authorNARUSE, Yui <naruse@users.sourceforge.jp>
Sun, 19 Oct 2008 18:32:59 +0000 (18:32 +0000)
committerNARUSE, Yui <naruse@users.sourceforge.jp>
Sun, 19 Oct 2008 18:32:59 +0000 (18:32 +0000)
nkf.c

diff --git a/nkf.c b/nkf.c
index 45e915b..faf1d62 100644 (file)
--- a/nkf.c
+++ b/nkf.c
@@ -31,7 +31,7 @@
  * \e$B8=:_!"\e(Bnkf \e$B$O\e(B SorceForge \e$B$K$F%a%s%F%J%s%9$,B3$1$i$l$F$$$^$9!#\e(B
  * http://sourceforge.jp/projects/nkf/
  ***********************************************************************/
-#define NKF_IDENT "$Id: nkf.c,v 1.181 2008/10/04 10:15:10 naruse Exp $"
+#define NKF_IDENT "$Id: nkf.c,v 1.182 2008/10/19 09:32:59 naruse Exp $"
 #define NKF_VERSION "2.0.8"
 #define NKF_RELEASE_DATE "2008-02-08"
 #define COPY_RIGHT \
 #include "config.h"
 #include "nkf.h"
 #include "utf8tbl.h"
+#ifdef __WIN32__
+#include <windows.h>
+#include <locale.h>
+#endif
 
 /* state of output_mode and input_mode
 
@@ -718,7 +722,16 @@ nkf_locale_charmap()
 #ifdef HAVE_LANGINFO_H
     return nl_langinfo(CODESET);
 #elif defined(__WIN32__)
-    return sprintf("CP%d", GetACP());
+    char buf[16];
+    char *str;
+    int len = sprintf(buf, "CP%d", GetACP());
+    if (len > 0) {
+      str = malloc(len + 1);
+      strcpy(str, buf);
+      str[len] = '\0';
+      return str;
+    }
+    else return NULL;
 #else
     return NULL;
 #endif