Fossil SCM

Always write UTF8 to the console. Change the console output mode on windows to UTF8 at startup.

drh 2011-05-10 13:29 windows-i18n
Commit ab934c6b09fd1d5d4a32e502263130125664ed63
-15
--- src/config.h
+++ src/config.h
@@ -123,21 +123,6 @@
123123
#else /* Generates a warning - but it always works */
124124
# define FOSSIL_INT_TO_PTR(X) ((void*)(X))
125125
# define FOSSIL_PTR_TO_INT(X) ((int)(X))
126126
#endif
127127
128
-
129
-/* Unset the following to disable internationalization code. */
130
-#ifndef FOSSIL_I18N
131
-# define FOSSIL_I18N 1
132
-#endif
133
-
134
-#if FOSSIL_I18N
135
-# include <locale.h>
136
-# include <langinfo.h>
137
-#endif
138
-#ifndef CODESET
139
-# undef FOSSIL_I18N
140
-# define FOSSIL_I18N 0
141
-#endif
142
-
143128
#endif /* _RC_COMPILE_ */
144129
--- src/config.h
+++ src/config.h
@@ -123,21 +123,6 @@
123 #else /* Generates a warning - but it always works */
124 # define FOSSIL_INT_TO_PTR(X) ((void*)(X))
125 # define FOSSIL_PTR_TO_INT(X) ((int)(X))
126 #endif
127
128
129 /* Unset the following to disable internationalization code. */
130 #ifndef FOSSIL_I18N
131 # define FOSSIL_I18N 1
132 #endif
133
134 #if FOSSIL_I18N
135 # include <locale.h>
136 # include <langinfo.h>
137 #endif
138 #ifndef CODESET
139 # undef FOSSIL_I18N
140 # define FOSSIL_I18N 0
141 #endif
142
143 #endif /* _RC_COMPILE_ */
144
--- src/config.h
+++ src/config.h
@@ -123,21 +123,6 @@
123 #else /* Generates a warning - but it always works */
124 # define FOSSIL_INT_TO_PTR(X) ((void*)(X))
125 # define FOSSIL_PTR_TO_INT(X) ((int)(X))
126 #endif
127
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
128 #endif /* _RC_COMPILE_ */
129
+6
--- src/main.c
+++ src/main.c
@@ -23,10 +23,13 @@
2323
#include <string.h>
2424
#include <time.h>
2525
#include <fcntl.h>
2626
#include <sys/types.h>
2727
#include <sys/stat.h>
28
+#ifdef _WIN32
29
+#include <windows.h>
30
+#endif
2831
2932
3033
#if INTERFACE
3134
3235
/*
@@ -233,11 +236,14 @@
233236
234237
sqlite3_config(SQLITE_CONFIG_LOG, fossil_sqlite_log, 0);
235238
g.now = time(0);
236239
g.argc = argc;
237240
g.argv = argv;
241
+#if defined(_WIN32)
238242
for(i=0; i<argc; i++) g.argv[i] = fossil_mbcs_to_utf8(argv[i]);
243
+ SetConsoleOutputCP(65001);
244
+#endif
239245
if( getenv("GATEWAY_INTERFACE")!=0 && !find_option("nocgi", 0, 0)){
240246
zCmdName = "cgi";
241247
}else if( argc<2 ){
242248
fossil_fatal("Usage: %s COMMAND ...\n"
243249
"\"%s help\" for a list of available commands\n"
244250
--- src/main.c
+++ src/main.c
@@ -23,10 +23,13 @@
23 #include <string.h>
24 #include <time.h>
25 #include <fcntl.h>
26 #include <sys/types.h>
27 #include <sys/stat.h>
 
 
 
28
29
30 #if INTERFACE
31
32 /*
@@ -233,11 +236,14 @@
233
234 sqlite3_config(SQLITE_CONFIG_LOG, fossil_sqlite_log, 0);
235 g.now = time(0);
236 g.argc = argc;
237 g.argv = argv;
 
238 for(i=0; i<argc; i++) g.argv[i] = fossil_mbcs_to_utf8(argv[i]);
 
 
239 if( getenv("GATEWAY_INTERFACE")!=0 && !find_option("nocgi", 0, 0)){
240 zCmdName = "cgi";
241 }else if( argc<2 ){
242 fossil_fatal("Usage: %s COMMAND ...\n"
243 "\"%s help\" for a list of available commands\n"
244
--- src/main.c
+++ src/main.c
@@ -23,10 +23,13 @@
23 #include <string.h>
24 #include <time.h>
25 #include <fcntl.h>
26 #include <sys/types.h>
27 #include <sys/stat.h>
28 #ifdef _WIN32
29 #include <windows.h>
30 #endif
31
32
33 #if INTERFACE
34
35 /*
@@ -233,11 +236,14 @@
236
237 sqlite3_config(SQLITE_CONFIG_LOG, fossil_sqlite_log, 0);
238 g.now = time(0);
239 g.argc = argc;
240 g.argv = argv;
241 #if defined(_WIN32)
242 for(i=0; i<argc; i++) g.argv[i] = fossil_mbcs_to_utf8(argv[i]);
243 SetConsoleOutputCP(65001);
244 #endif
245 if( getenv("GATEWAY_INTERFACE")!=0 && !find_option("nocgi", 0, 0)){
246 zCmdName = "cgi";
247 }else if( argc<2 ){
248 fossil_fatal("Usage: %s COMMAND ...\n"
249 "\"%s help\" for a list of available commands\n"
250
+1 -17
--- src/printf.c
+++ src/printf.c
@@ -806,27 +806,11 @@
806806
** On windows, transform the output into the current terminal encoding
807807
** if the output is going to the screen. If output is redirected into
808808
** a file, no translation occurs. No translation ever occurs on unix.
809809
*/
810810
void fossil_puts(const char *z, int toStdErr){
811
-#if defined(_WIN32)
812
- extern char *sqlite3_win32_utf8_to_mbcs(const char*);
813
- static int once = 1;
814
- static int istty[2];
815
- char *zToFree = 0;
816
- if( once ){
817
- istty[0] = _isatty(fileno(stdout));
818
- istty[1] = _isatty(fileno(stderr));
819
- once = 0;
820
- }
821
- assert( toStdErr==0 || toStdErr==1 );
822
- if( istty[toStdErr] ) z = zToFree = sqlite3_win32_utf8_to_mbcs(z);
823
- fwrite(z, 1, strlen(z), toStdErr ? stderr : stdout);
824
- free(zToFree);
825
-#else
826
- fwrite(z, 1, strlen(z), toStdErr ? stderr : stdout);
827
-#endif
811
+ fwrite(z, 1, strlen(z), toStdErr ? stderr : stdout);
828812
}
829813
830814
/*
831815
** Write output for user consumption. If g.cgiOutput is enabled, then
832816
** send the output as part of the CGI reply. If g.cgiOutput is false,
833817
--- src/printf.c
+++ src/printf.c
@@ -806,27 +806,11 @@
806 ** On windows, transform the output into the current terminal encoding
807 ** if the output is going to the screen. If output is redirected into
808 ** a file, no translation occurs. No translation ever occurs on unix.
809 */
810 void fossil_puts(const char *z, int toStdErr){
811 #if defined(_WIN32)
812 extern char *sqlite3_win32_utf8_to_mbcs(const char*);
813 static int once = 1;
814 static int istty[2];
815 char *zToFree = 0;
816 if( once ){
817 istty[0] = _isatty(fileno(stdout));
818 istty[1] = _isatty(fileno(stderr));
819 once = 0;
820 }
821 assert( toStdErr==0 || toStdErr==1 );
822 if( istty[toStdErr] ) z = zToFree = sqlite3_win32_utf8_to_mbcs(z);
823 fwrite(z, 1, strlen(z), toStdErr ? stderr : stdout);
824 free(zToFree);
825 #else
826 fwrite(z, 1, strlen(z), toStdErr ? stderr : stdout);
827 #endif
828 }
829
830 /*
831 ** Write output for user consumption. If g.cgiOutput is enabled, then
832 ** send the output as part of the CGI reply. If g.cgiOutput is false,
833
--- src/printf.c
+++ src/printf.c
@@ -806,27 +806,11 @@
806 ** On windows, transform the output into the current terminal encoding
807 ** if the output is going to the screen. If output is redirected into
808 ** a file, no translation occurs. No translation ever occurs on unix.
809 */
810 void fossil_puts(const char *z, int toStdErr){
811 fwrite(z, 1, strlen(z), toStdErr ? stderr : stdout);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
812 }
813
814 /*
815 ** Write output for user consumption. If g.cgiOutput is enabled, then
816 ** send the output as part of the CGI reply. If g.cgiOutput is false,
817

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button