Fossil SCM

Back out the [ab934c6b09fd1d5] change. Do not change the console output mode using SetConsoleOutputCP(). Go back to converting UTF8 into MBCS upon output.

drh 2011-05-12 12:13 windows-i18n merge
Commit b33032ae401a8d6cfdc6d27f1699d28386710364
2 files changed -6 +16
-6
--- src/main.c
+++ src/main.c
@@ -23,13 +23,10 @@
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
3128
3229
3330
#if INTERFACE
3431
3532
/*
@@ -236,14 +233,11 @@
236233
237234
sqlite3_config(SQLITE_CONFIG_LOG, fossil_sqlite_log, 0);
238235
g.now = time(0);
239236
g.argc = argc;
240237
g.argv = argv;
241
-#if defined(_WIN32)
242238
for(i=0; i<argc; i++) g.argv[i] = fossil_mbcs_to_utf8(argv[i]);
243
- SetConsoleOutputCP(65001);
244
-#endif
245239
if( getenv("GATEWAY_INTERFACE")!=0 && !find_option("nocgi", 0, 0)){
246240
zCmdName = "cgi";
247241
}else if( argc<2 ){
248242
fossil_fatal("Usage: %s COMMAND ...\n"
249243
"\"%s help\" for a list of available commands\n"
250244
--- src/main.c
+++ src/main.c
@@ -23,13 +23,10 @@
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 /*
@@ -236,14 +233,11 @@
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
--- src/main.c
+++ src/main.c
@@ -23,13 +23,10 @@
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 /*
@@ -236,14 +233,11 @@
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
+16
--- src/printf.c
+++ src/printf.c
@@ -806,11 +806,27 @@
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
811826
fwrite(z, 1, strlen(z), toStdErr ? stderr : stdout);
827
+#endif
812828
}
813829
814830
/*
815831
** Write output for user consumption. If g.cgiOutput is enabled, then
816832
** send the output as part of the CGI reply. If g.cgiOutput is false,
817833
--- src/printf.c
+++ src/printf.c
@@ -806,11 +806,27 @@
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
--- src/printf.c
+++ src/printf.c
@@ -806,11 +806,27 @@
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

Keyboard Shortcuts

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