]> wimlib.net Git - wimlib/blobdiff - src/wim.c
Move FreeLibrary call to win32_global_cleanup()
[wimlib] / src / wim.c
index 45b9fd627e610afb903e587294265de4728b651a..823d3a4423024d7155c0c2bbe97a14d8c211488f 100644 (file)
--- a/src/wim.c
+++ b/src/wim.c
@@ -27,7 +27,6 @@
 
 #include <errno.h>
 #include <fcntl.h>
-#include <langinfo.h>
 #include <limits.h>
 #include <stdarg.h>
 #include <stdlib.h>
@@ -40,6 +39,8 @@
 
 #ifdef __WIN32__
 #  include "win32.h"
+#else
+#  include <langinfo.h>
 #endif
 
 #include "buffer_io.h"
@@ -669,7 +670,16 @@ wimlib_free(WIMStruct *w)
        DEBUG("Freed WIMStruct");
 }
 
-bool wimlib_mbs_is_utf8;
+static bool
+test_locale_ctype_utf8()
+{
+       char *ctype = nl_langinfo(CODESET);
+
+       return (strstr(ctype, "UTF-8") == 0 ||
+               strstr(ctype, "UTF8") == 0 ||
+               strstr(ctype, "utf8") == 0 ||
+               strstr(ctype, "utf-8") == 0);
+}
 
 /* Get global memory allocations out of the way.  Not strictly necessary in
  * single-threaded programs like 'imagex'. */
@@ -680,7 +690,10 @@ wimlib_global_init()
 #ifdef WITH_NTFS_3G
        libntfs3g_global_init();
 #endif
-       wimlib_mbs_is_utf8 = (strcmp(nl_langinfo(CODESET), "UTF-8") == 0);
+       wimlib_mbs_is_utf8 = test_locale_ctype_utf8();
+#ifdef __WIN32__
+       win32_global_init();
+#endif
        return 0;
 }
 
@@ -691,4 +704,7 @@ wimlib_global_cleanup()
 {
        libxml_global_cleanup();
        iconv_global_cleanup();
+#ifdef __WIN32__
+       win32_global_cleanup();
+#endif
 }