]> wimlib.net Git - wimlib/blobdiff - src/wim.c
Update docs
[wimlib] / src / wim.c
index 45b9fd627e610afb903e587294265de4728b651a..667d076b6859ecca519828f36ef79aa8e8b5dc83 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,7 @@ 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();
        return 0;
 }