Fossil

Check-in [ab934c6b]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Always write UTF8 to the console. Change the console output mode on windows to UTF8 at startup.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | windows-i18n
Files: files | file ages | folders
SHA1: ab934c6b09fd1d5d4a32e502263130125664ed63
User & Date: drh 2011-05-10 13:29:54
References
2011-05-12
12:13
Back out the [ab934c6b09fd1d5] change. Do not change the console output mode using SetConsoleOutputCP(). Go back to converting UTF8 into MBCS upon output. check-in: b33032ae user: drh tags: windows-i18n
Context
2011-05-10
13:38
Translate check-in comments received from console input from MBCS into UTF8. check-in: 2278ef0f user: drh tags: windows-i18n
13:29
Always write UTF8 to the console. Change the console output mode on windows to UTF8 at startup. check-in: ab934c6b user: drh tags: windows-i18n
2011-05-09
15:50
Pull the latest trunk changes over into the windows-i18n branch. check-in: bbba1608 user: drh tags: windows-i18n
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/config.h.

121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# define FOSSIL_INT_TO_PTR(X)  ((void*)&((char*)0)[X])
# define FOSSIL_PTR_TO_INT(X)  ((int)(((char*)X)-(char*)0))
#else                          /* Generates a warning - but it always works */
# define FOSSIL_INT_TO_PTR(X)  ((void*)(X))
# define FOSSIL_PTR_TO_INT(X)  ((int)(X))
#endif


/* Unset the following to disable internationalization code. */
#ifndef FOSSIL_I18N
# define FOSSIL_I18N 1
#endif

#if FOSSIL_I18N
# include <locale.h>
# include <langinfo.h>
#endif
#ifndef CODESET
# undef FOSSIL_I18N
# define FOSSIL_I18N 0
#endif

#endif /* _RC_COMPILE_ */







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<

121
122
123
124
125
126
127















128
# define FOSSIL_INT_TO_PTR(X)  ((void*)&((char*)0)[X])
# define FOSSIL_PTR_TO_INT(X)  ((int)(((char*)X)-(char*)0))
#else                          /* Generates a warning - but it always works */
# define FOSSIL_INT_TO_PTR(X)  ((void*)(X))
# define FOSSIL_PTR_TO_INT(X)  ((int)(X))
#endif
















#endif /* _RC_COMPILE_ */

Changes to src/main.c.

21
22
23
24
25
26
27



28
29
30
31
32
33
34
...
231
232
233
234
235
236
237

238


239
240
241
242
243
244
245
#include "config.h"
#include "main.h"
#include <string.h>
#include <time.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>





#if INTERFACE

/*
** Number of elements in an array
*/
................................................................................
  int rc;
  int i;

  sqlite3_config(SQLITE_CONFIG_LOG, fossil_sqlite_log, 0);
  g.now = time(0);
  g.argc = argc;
  g.argv = argv;

  for(i=0; i<argc; i++) g.argv[i] = fossil_mbcs_to_utf8(argv[i]);


  if( getenv("GATEWAY_INTERFACE")!=0 && !find_option("nocgi", 0, 0)){
    zCmdName = "cgi";
  }else if( argc<2 ){
    fossil_fatal("Usage: %s COMMAND ...\n"
                 "\"%s help\" for a list of available commands\n"
                 "\"%s help COMMAND\" for specific details\n",
                 argv[0], argv[0], argv[0]);







>
>
>







 







>

>
>







21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
...
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
#include "config.h"
#include "main.h"
#include <string.h>
#include <time.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#ifdef _WIN32
#include <windows.h>
#endif


#if INTERFACE

/*
** Number of elements in an array
*/
................................................................................
  int rc;
  int i;

  sqlite3_config(SQLITE_CONFIG_LOG, fossil_sqlite_log, 0);
  g.now = time(0);
  g.argc = argc;
  g.argv = argv;
#if defined(_WIN32)
  for(i=0; i<argc; i++) g.argv[i] = fossil_mbcs_to_utf8(argv[i]);
  SetConsoleOutputCP(65001);
#endif
  if( getenv("GATEWAY_INTERFACE")!=0 && !find_option("nocgi", 0, 0)){
    zCmdName = "cgi";
  }else if( argc<2 ){
    fossil_fatal("Usage: %s COMMAND ...\n"
                 "\"%s help\" for a list of available commands\n"
                 "\"%s help COMMAND\" for specific details\n",
                 argv[0], argv[0], argv[0]);

Changes to src/printf.c.

804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
** Write to standard output or standard error.
**
** On windows, transform the output into the current terminal encoding
** if the output is going to the screen.  If output is redirected into
** a file, no translation occurs.  No translation ever occurs on unix.
*/
void fossil_puts(const char *z, int toStdErr){
#if defined(_WIN32)
  extern char *sqlite3_win32_utf8_to_mbcs(const char*);
  static int once = 1;
  static int istty[2];
  char *zToFree = 0;
  if( once ){
    istty[0] = _isatty(fileno(stdout));
    istty[1] = _isatty(fileno(stderr));
    once = 0;
  }
  assert( toStdErr==0 || toStdErr==1 );
  if( istty[toStdErr] ) z = zToFree = sqlite3_win32_utf8_to_mbcs(z);
  fwrite(z, 1, strlen(z), toStdErr ? stderr : stdout);
  free(zToFree);
#else
  fwrite(z, 1, strlen(z), toStdErr ? stderr : stdout);
#endif
}

/*
** Write output for user consumption.  If g.cgiOutput is enabled, then
** send the output as part of the CGI reply.  If g.cgiOutput is false,
** then write on standard output.
*/







<
<
<
<
<
<
<
<
<
<
<
<

<
<
<
<







804
805
806
807
808
809
810












811




812
813
814
815
816
817
818
** Write to standard output or standard error.
**
** On windows, transform the output into the current terminal encoding
** if the output is going to the screen.  If output is redirected into
** a file, no translation occurs.  No translation ever occurs on unix.
*/
void fossil_puts(const char *z, int toStdErr){












  fwrite(z, 1, strlen(z), toStdErr ? stderr : stdout);




}

/*
** Write output for user consumption.  If g.cgiOutput is enabled, then
** send the output as part of the CGI reply.  If g.cgiOutput is false,
** then write on standard output.
*/