aboutsummaryrefslogtreecommitdiffstats
path: root/utils/openal-info.c
diff options
context:
space:
mode:
Diffstat (limited to 'utils/openal-info.c')
-rw-r--r--utils/openal-info.c69
1 files changed, 5 insertions, 64 deletions
diff --git a/utils/openal-info.c b/utils/openal-info.c
index 1788d118..4bb73e76 100644
--- a/utils/openal-info.c
+++ b/utils/openal-info.c
@@ -46,70 +46,6 @@
#endif
-#ifdef _WIN32
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-
-static WCHAR *FromUTF8(const char *str)
-{
- WCHAR *out = NULL;
- int len;
-
- if((len=MultiByteToWideChar(CP_UTF8, 0, str, -1, NULL, 0)) > 0)
- {
- out = calloc(sizeof(WCHAR), (unsigned int)(len));
- MultiByteToWideChar(CP_UTF8, 0, str, -1, out, len);
- }
- return out;
-}
-
-/* Override printf, fprintf, and fwrite so we can print UTF-8 strings. */
-static void al_fprintf(FILE *file, const char *fmt, ...)
-{
- char str[1024];
- WCHAR *wstr;
- va_list ap;
-
- va_start(ap, fmt);
- vsnprintf(str, sizeof(str), fmt, ap);
- va_end(ap);
-
- str[sizeof(str)-1] = 0;
- wstr = FromUTF8(str);
- if(!wstr)
- fprintf(file, "<UTF-8 error> %s", str);
- else
- fprintf(file, "%ls", wstr);
- free(wstr);
-}
-#define fprintf al_fprintf
-#define printf(...) al_fprintf(stdout, __VA_ARGS__)
-
-static size_t al_fwrite(const void *ptr, size_t size, size_t nmemb, FILE *file)
-{
- char str[1024];
- WCHAR *wstr;
- size_t len;
-
- len = size * nmemb;
- if(len > sizeof(str)-1)
- len = sizeof(str)-1;
- memcpy(str, ptr, len);
- str[len] = 0;
-
- wstr = FromUTF8(str);
- if(!wstr)
- fprintf(file, "<UTF-8 error> %s", str);
- else
- fprintf(file, "%ls", wstr);
- free(wstr);
-
- return len / size;
-}
-#define fwrite al_fwrite
-#endif
-
-
#define MAX_WIDTH 80
static void printList(const char *list, char separator)
@@ -384,6 +320,11 @@ int main(int argc, char *argv[])
ALCdevice *device;
ALCcontext *context;
+#ifdef _WIN32
+ /* OpenAL Soft gives UTF-8 strings, so set the console to expect that. */
+ SetConsoleOutputCP(CP_UTF8);
+#endif
+
if(argc > 1 && (strcmp(argv[1], "--help") == 0 ||
strcmp(argv[1], "-h") == 0))
{