Index: configure.ac
===================================================================
--- configure.ac	(revision 5470)
+++ configure.ac	(working copy)
@@ -2923,6 +2923,15 @@
 	fi
 fi
 
+dnl ############## Enable UNICODE
+
+if test x$win32_specific_codes = xenabled; then
+	dnl We cannot put -municode in CFLAGS because libtool gets very confused and breaks.
+	UNICODE_CFLAGS="-municode"
+fi
+
+AC_SUBST(UNICODE_CFLAGS)
+
 dnl ############## Library cleanup
 
 PROG_LIBS=$LIBS
Index: Makefile.am
===================================================================
--- Makefile.am	(revision 5470)
+++ Makefile.am	(working copy)
@@ -7,6 +7,8 @@
 
 # Mention all global variables first before including Make modules.
 ACLOCAL_AMFLAGS = -I m4
+AM_CPPFLAGS =
+AM_CFLAGS =
 bin_PROGRAMS =
 EXTRA_PROGRAMS =
 EXTRA_DIST =
@@ -30,9 +32,11 @@
 XFAIL_TESTS =
 check_PROGRAMS =
 
-AM_CPPFLAGS = -DPKGLIBDIR="\"$(pkglibdir)\""
+AM_CPPFLAGS += -DPKGLIBDIR="\"$(pkglibdir)\""
 AM_CPPFLAGS += $(LTDLINCL)
 
+AM_CFLAGS += $(UNICODE_CFLAGS)
+
 # Central place defining the mpg123 libraries to be used. You could
 # put -lmpg123 in here to use an external one (for whatever reason).
 LIBMPG123 = src/libmpg123/libmpg123.la
Index: src/Makemodule.am
===================================================================
--- src/Makemodule.am	(revision 5470)
+++ src/Makemodule.am	(working copy)
@@ -166,4 +166,7 @@
 
 src_mpg123_id3dump_SOURCES += \
   src/win32_support.c
+
+src_mpg123_strip_SOURCES += \
+  src/win32_support.c
 endif
Index: src/mpg123-id3dump.c
===================================================================
--- src/mpg123-id3dump.c	(revision 5470)
+++ src/mpg123-id3dump.c	(working copy)
@@ -359,12 +359,19 @@
 	}
 }
 
+#if defined(UNICODE)
+int wmain(int argc, wchar_t ** wargv)
+{
+	char **argv;
+#else
 int main(int argc, char **argv)
 {
+#endif
 	int i, result;
 	mpg123_handle* m;
 #if defined(WANT_WIN32_UNICODE)
-	win32_cmdline_utf8(&argc,&argv);
+	argv = NULL;
+	win32_cmdline_utf8(argc, &argv, wargv);
 #endif
 	progname = argv[0];
 
@@ -429,8 +436,10 @@
 	mpg123_exit();
 
 	if(errors) error1("Encountered %i errors along the way.", errors);
-	return errors != 0;
+
 #if defined(WANT_WIN32_UNICODE)
-	win32_cmdline_free(argc,argv);
+	win32_cmdline_free(argc, argv);
 #endif
+
+	return errors != 0;
 }
Index: src/mpg123-strip.c
===================================================================
--- src/mpg123-strip.c	(revision 5470)
+++ src/mpg123-strip.c	(working copy)
@@ -9,6 +9,7 @@
 #include "config.h"
 #include "version.h"
 #include "compat/compat.h"
+#include "win32_support.h"
 
 #if defined(WIN32) && defined(DYNAMIC_BUILD)
 #define LINK_MPG123_DLL
@@ -72,11 +73,22 @@
 
 int do_work(mpg123_handle *m);
 
+#if defined(UNICODE)
+int wmain(int argc, wchar_t ** wargv)
+{
+	char **argv;
+#else
 int main(int argc, char **argv)
 {
+#endif
 	int ret = 0;
 	mpg123_handle *m;
 
+#if defined(WANT_WIN32_UNICODE)
+	argv = NULL;
+	win32_cmdline_utf8(argc, &argv, wargv);
+#endif
+
 	progname = argv[0];
 
 	while ((ret = getlopt(argc, argv, opts)))
@@ -127,6 +139,10 @@
 	}
 	mpg123_exit();
 
+#if defined(WANT_WIN32_UNICODE)
+	win32_cmdline_free(argc, argv);
+#endif
+
 	return ret;
 }
 
Index: src/mpg123.c
===================================================================
--- src/mpg123.c	(revision 5470)
+++ src/mpg123.c	(working copy)
@@ -980,8 +980,15 @@
 	}
 }
 
+
+#if defined(UNICODE)
+int wmain(int sys_argc, wchar_t ** sys_wargv)
+{
+	char **sys_argv;
+#else
 int main(int sys_argc, char ** sys_argv)
 {
+#endif
 	int result;
 	char end_of_files = FALSE;
 	long parr;
@@ -995,16 +1002,16 @@
 #endif
 	aux_out = stdout; /* Need to initialize here because stdout is not a constant?! */
 #if defined (WANT_WIN32_UNICODE)
-	if(win32_cmdline_utf8(&argc, &argv) != 0)
+	sys_argv = NULL;
+	if(win32_cmdline_utf8(sys_argc, &sys_argv, sys_wargv) != 0)
 	{
 		error("Cannot convert command line to UTF8!");
 		safe_exit(76);
 	}
 	args_utf8 = TRUE;
-#else
+#endif
 	argv = sys_argv;
 	argc = sys_argc;
-#endif
 #if defined (WANT_WIN32_SOCKETS)
 	win32_net_init();
 #endif
@@ -1013,8 +1020,11 @@
 	/* Despite in Unicode form, the path munging backend is still in ANSI/ASCII
 	 * so using _wpgmptr with unicode paths after UTF8 conversion is broken on Windows
 	 */
-	
+#if defined(UNICODE)
+	INT123_win32_wide_utf8(_wpgmptr, &fullprogname, NULL);
+#else
 	fullprogname = INT123_compat_strdup(_pgmptr);
+#endif
 #else
 	fullprogname = INT123_compat_strdup(argv[0]);
 #endif
Index: src/out123.c
===================================================================
--- src/out123.c	(revision 5470)
+++ src/out123.c	(working copy)
@@ -1465,22 +1465,28 @@
 }
 
 
+#if defined(UNICODE)
+int wmain(int sys_argc, wchar_t ** sys_wargv)
+{
+	char **sys_argv;
+#else
 int main(int sys_argc, char ** sys_argv)
 {
+#endif
 	int result;
 	INT123_compat_binmode(STDIN_FILENO, TRUE);
 	check_locale();
 
 #if defined (WANT_WIN32_UNICODE)
-	if(win32_cmdline_utf8(&argc, &argv) != 0)
+	sys_argv = NULL;
+	if(win32_cmdline_utf8(sys_argc, &sys_argv, sys_wargv) != 0)
 	{
 		error("Cannot convert command line to UTF8!");
 		safe_exit(76);
 	}
-#else
+#endif
 	argv = sys_argv;
 	argc = sys_argc;
-#endif
 
 	if(!(fullprogname = INT123_compat_strdup(argv[0])))
 	{
Index: src/win32_support.c
===================================================================
--- src/win32_support.c	(revision 5470)
+++ src/win32_support.c	(working copy)
@@ -4,41 +4,18 @@
 
 #ifdef WANT_WIN32_UNICODE
 
-/* Obscure and undocumented call from MS C Runtime "MSVCRT.DLL" */
-typedef struct
+int win32_cmdline_utf8(int argc, char *** argv, wchar_t ** argv_wide)
 {
-	int newmode;
-} _startupinfo;
-
-/* XP and later has an int return though */
-int __cdecl __declspec(dllimport) __wgetmainargs (
-	int *_Argc,
-	wchar_t ***_Argv,
-	wchar_t ***_Env,
-	int _DoWildCard,
-	_startupinfo * _StartInfo
-);
-
-int win32_cmdline_utf8(int * argc, char *** argv)
-{
 	int argcounter;
-	wchar_t **argv_wide;
-	wchar_t **env;
 	char *argvptr;
-	_startupinfo startup;
 
 	/* That's too lame. */
-	if(argv == NULL || argc == NULL) return -1;
+	if(argv == NULL || argv_wide == NULL) return -1;
 
-	startup.newmode = 0;
-	if (__wgetmainargs(argc, &argv_wide, &env, 1, &startup) != 0) {
-		error("Cannot allocate memory for command line.");
-		return -1;
-	}
-	*argv = (char **)calloc(sizeof (char *), *argc);
+	*argv = (char **)calloc(sizeof (char *), argc);
 	if(*argv == NULL){ error("Cannot allocate memory for command line."); return -1; }
 
-	for(argcounter = 0; argcounter < *argc; argcounter++)
+	for(argcounter = 0; argcounter < argc; argcounter++)
 	{
 		INT123_win32_wide_utf8(argv_wide[argcounter], &argvptr, NULL);
 		(*argv)[argcounter] = argvptr;
Index: src/win32_support.h
===================================================================
--- src/win32_support.h	(revision 5470)
+++ src/win32_support.h	(working copy)
@@ -89,10 +89,10 @@
 
 #ifdef WANT_WIN32_UNICODE
 /**
- * Put the windows command line into argv / argc, encoded in UTF-8.
+ * Put the windows wchar_t command line from wargv into argv, encoded in UTF-8.
  * You are supposed to free up resources by calling win32_cmdline_free with the values you got from this one.
  * @return 0 on success, -1 on error */
-int win32_cmdline_utf8(int * argc, char *** argv);
+int win32_cmdline_utf8(int argc, char *** argv, wchar_t ** argv_wide);
 
 /**
  * Free up cmdline memory (the argv itself, theoretically hidden resources, too).
