1.1 --- a/bookloupe/bookloupe.c Thu May 30 18:33:44 2013 +0100
1.2 +++ b/bookloupe/bookloupe.c Thu May 30 19:26:24 2013 +0100
1.3 @@ -22,6 +22,9 @@
1.4 #include <stdlib.h>
1.5 #include <string.h>
1.6 #include <ctype.h>
1.7 +#ifdef __WIN32__
1.8 +#include <windows.h>
1.9 +#endif
1.10 #include <glib.h>
1.11 #include <bl/bl.h>
1.12 #include "HTMLentities.h"
1.13 @@ -235,6 +238,10 @@
1.14
1.15 GTree *qword,*qperiod;
1.16
1.17 +#ifdef __WIN32__
1.18 +UINT saved_cp;
1.19 +#endif
1.20 +
1.21 struct first_pass_results {
1.22 long firstline,astline;
1.23 long footerline,totlen,binlen,alphalen,endquote_count,shortline,dotcomma;
1.24 @@ -405,18 +412,35 @@
1.25 {
1.26 utf8=g_utf8_normalize(contents,len,G_NORMALIZE_DEFAULT_COMPOSE);
1.27 g_set_print_handler(print_as_utf_8);
1.28 +#ifdef __WIN32__
1.29 + SetConsoleOutputCP(CP_UTF8);
1.30 +#endif
1.31 }
1.32 else
1.33 {
1.34 utf8=g_convert(contents,len,"UTF-8","WINDOWS-1252",NULL,&nb,NULL);
1.35 g_set_print_handler(print_as_windows_1252);
1.36 +#ifdef __WIN32__
1.37 + SetConsoleOutputCP(1252);
1.38 +#endif
1.39 }
1.40 g_free(contents);
1.41 return utf8;
1.42 }
1.43
1.44 +void cleanup_on_exit(void)
1.45 +{
1.46 +#ifdef __WIN32__
1.47 + SetConsoleOutputCP(saved_cp);
1.48 +#endif
1.49 +}
1.50 +
1.51 int main(int argc,char **argv)
1.52 {
1.53 +#ifdef __WIN32__
1.54 + atexit(cleanup_on_exit);
1.55 + saved_cp=GetConsoleOutputCP();
1.56 +#endif
1.57 running_from=g_path_get_dirname(argv[0]);
1.58 parse_options(&argc,&argv);
1.59 if (pswit[USERTYPO_SWITCH])