ADDED   .project
Index: .project
==================================================================
--- .project
+++ .project
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>fossil</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+	</buildSpec>
+	<natures>
+	</natures>
+</projectDescription>

ADDED   .settings/org.eclipse.core.resources.prefs
Index: .settings/org.eclipse.core.resources.prefs
==================================================================
--- .settings/org.eclipse.core.resources.prefs
+++ .settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+encoding/<project>=UTF-8

ADDED   .settings/org.eclipse.core.runtime.prefs
Index: .settings/org.eclipse.core.runtime.prefs
==================================================================
--- .settings/org.eclipse.core.runtime.prefs
+++ .settings/org.eclipse.core.runtime.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+line.separator=\n

Index: src/add.c
==================================================================
--- src/add.c
+++ src/add.c
@@ -39,11 +39,11 @@
 */
 const char *fossil_reserved_name(int N){
   /* Possible names of the local per-checkout database file and
   ** its associated journals
   */
-  static const char *azName[] = {
+  static const char *const azName[] = {
      "_FOSSIL_",
      "_FOSSIL_-journal",
      "_FOSSIL_-wal",
      "_FOSSIL_-shm",
      ".fslckout",
@@ -61,11 +61,11 @@
   };
 
   /* Names of auxiliary files generated by SQLite when the "manifest"
   ** properity is enabled
   */
-  static const char *azManifest[] = {
+  static const char *const azManifest[] = {
      "manifest",
      "manifest.uuid",
   };
 
   /* Cached setting "manifest" */
@@ -531,11 +531,11 @@
 ** See also: changes, status
 */
 void mv_cmd(void){
   int i;
   int vid;
-  char *zDest;
+  const char *zDest;
   Blob dest;
   Stmt q;
 
   db_must_be_within_tree();
   vid = db_lget_int("checkout", 0);

Index: src/allrepo.c
==================================================================
--- src/allrepo.c
+++ src/allrepo.c
@@ -199,11 +199,11 @@
   /* If any repositories whose names appear in the ~/.fossil file could not
   ** be found, remove those names from the ~/.fossil file.
   */
   if( bag_count(&outOfDate)>0 ){
     Blob sql;
-    char *zSep = "(";
+    const char *zSep = "(";
     int rowid;
     blob_zero(&sql);
     blob_appendf(&sql, "DELETE FROM global_config WHERE rowid IN ");
     for(rowid=bag_first(&outOfDate); rowid>0; rowid=bag_next(&outOfDate,rowid)){
       blob_appendf(&sql, "%s%d", zSep, rowid);

Index: src/blob.c
==================================================================
--- src/blob.c
+++ src/blob.c
@@ -767,22 +767,16 @@
 int blob_write_to_file(Blob *pBlob, const char *zFilename){
   FILE *out;
   int wrote;
 
   if( zFilename[0]==0 || (zFilename[0]=='-' && zFilename[1]==0) ){
-    int n;
+    int n = blob_size(pBlob);
 #if defined(_WIN32)
-    if( _isatty(fileno(stdout)) ){
-      char *z;
-      z = fossil_utf8_to_console(blob_str(pBlob));
-      n = strlen(z);
-      fwrite(z, 1, n, stdout);
-      free(z);
+    if( fossil_utf8_to_console(blob_buffer(pBlob), n, 0) >= 0 ){
       return n;
     }
 #endif
-    n = blob_size(pBlob);
     fwrite(blob_buffer(pBlob), 1, n, stdout);
     return n;
   }else{
     int i, nName;
     char *zName, zBuf[1000];

Index: src/branch.c
==================================================================
--- src/branch.c
+++ src/branch.c
@@ -165,11 +165,11 @@
       "\n"
       "Note: the local check-out has not been updated to the new\n"
       "      branch.  To begin working on the new branch, do this:\n"
       "\n"
       "      %s update %s\n",
-      fossil_nameofexe(), zBranch
+      g.argv[0], zBranch
     );
   }
 
 
   /* Commit */

Index: src/captcha.c
==================================================================
--- src/captcha.c
+++ src/captcha.c
@@ -98,11 +98,11 @@
 }
 #endif /* CAPTCHA==1 */
 
 
 #if CAPTCHA==2
-static const char *azFont2[] = {
+static const char *const azFont2[] = {
  /* 0 */
  "  __  ",
  " /  \\ ",
  "| () |",
  " \\__/ ",
@@ -223,11 +223,11 @@
   return z;     
 }
 #endif /* CAPTCHA==2 */
 
 #if CAPTCHA==3
-static const char *azFont3[] = {
+static const char *const azFont3[] = {
   /* 0 */
   "  ___  ",
   " / _ \\ ",
   "| | | |",
   "| | | |",

Index: src/cgi.c
==================================================================
--- src/cgi.c
+++ src/cgi.c
@@ -1355,13 +1355,13 @@
 
 
 /*
 ** Name of days and months.
 */
-static const char *azDays[] =
+static const char *const azDays[] =
     {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", 0};
-static const char *azMonths[] =
+static const char *const azMonths[] =
     {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
      "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", 0};
 
 
 /*

Index: src/checkout.c
==================================================================
--- src/checkout.c
+++ src/checkout.c
@@ -186,11 +186,11 @@
 */
 void checkout_cmd(void){
   int forceFlag;                 /* Force checkout even if edits exist */
   int keepFlag;                  /* Do not change any files on disk */
   int latestFlag;                /* Checkout the latest version */
-  char *zVers;                   /* Version to checkout */
+  const char *zVers;             /* Version to checkout */
   int promptFlag;                /* True to prompt before overwriting */
   int vid, prior;
   Blob cksum1, cksum1b, cksum2;
   
   db_must_be_within_tree();

Index: src/clearsign.c
==================================================================
--- src/clearsign.c
+++ src/clearsign.c
@@ -28,11 +28,11 @@
 */
 int clearsign(Blob *pIn, Blob *pOut){
   char *zRand;
   char *zIn;
   char *zOut;
-  char *zBase = db_get("pgp-command", "gpg --clearsign -o ");
+  const char *zBase = db_get("pgp-command", "gpg --clearsign -o ");
   char *zCmd;
   int rc;
   if( is_false(zBase) ){
     return 0;
   }

Index: src/configure.c
==================================================================
--- src/configure.c
+++ src/configure.c
@@ -916,12 +916,12 @@
       }
     }
     db_end_transaction(0);
     fossil_print("Configuration reset to factory defaults.\n");
     fossil_print("To recover, use:  %s %s import %s\n", 
-            fossil_nameofexe(), g.argv[1], zBackup);
+            g.argv[0], g.argv[1], zBackup);
   }else
   {
     fossil_fatal("METHOD should be one of:"
                  " export import merge pull push reset");
   }
 }

Index: src/db.c
==================================================================
--- src/db.c
+++ src/db.c
@@ -92,11 +92,13 @@
     g.cgiOutput = 0;
     cgi_printf("<h1>Database Error</h1>\n"
                "<pre>%h</pre><p>%s</p>", z, zRebuildMsg);
     cgi_reply();
   }else{
-    fprintf(stderr, "%s: %s\n\n%s", fossil_nameofexe(), z, zRebuildMsg);
+    char *zOut = mprintf("%s: %s\n\n%s", g.argv[0], z, zRebuildMsg);
+    fossil_puts(zOut, 1);
+    fossil_free(zOut);
   }
   free(z);
   db_force_rollback();
   fossil_exit(rc);
 }

Index: src/diff.c
==================================================================
--- src/diff.c
+++ src/diff.c
@@ -1649,11 +1649,11 @@
 ** being annotated.  Do another step of the annotation.  Return true
 ** if additional annotation is required.  zPName is the tag to insert
 ** on each line of the file being annotated that was contributed by
 ** pParent.  Memory to hold zPName is leaked.
 */
-static int annotation_step(Annotator *p, Blob *pParent, char *zPName){
+static int annotation_step(Annotator *p, Blob *pParent, const char *zPName){
   int i, j;
   int lnTo;
   int iPrevLevel;
   int iThisLevel;
 

Index: src/diffcmd.c
==================================================================
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -287,12 +287,12 @@
     int isDeleted = db_column_int(&q, 1);
     int isChnged = db_column_int(&q,2);
     int isNew = db_column_int(&q,3);
     int srcid = db_column_int(&q, 4);
     int isLink = db_column_int(&q, 5);
-    char *zFullName = mprintf("%s%s", g.zLocalRoot, zPathname);
-    char *zToFree = zFullName;
+    char *zToFree = mprintf("%s%s", g.zLocalRoot, zPathname);
+    const char *zFullName = zToFree;
     int showDiff = 1;
     if( isDeleted ){
       fossil_print("DELETED  %s\n", zPathname);
       if( !asNewFile ){ showDiff = 0; zFullName = NULL_DEVICE; }
     }else if( file_access(zFullName, 0) ){

Index: src/file.c
==================================================================
--- src/file.c
+++ src/file.c
@@ -1116,47 +1116,70 @@
 #endif
   return zValue;
 }
 
 /*
-** Translate UTF8 to MBCS for display on the console.  Return a pointer to the
-** translated text..  Call fossil_mbcs_free() to deallocate any memory
-** used to store the returned pointer when done.
+** Display UTF8 on the console.  Return the number of
+** Characters written. If stdout or stderr is redirected
+** to a file, -1 is returned and nothing is written
+** to the console.
 */
-char *fossil_utf8_to_console(const char *zUtf8){
+int fossil_utf8_to_console(const char *zUtf8, int nByte, int toStdErr){
 #ifdef _WIN32
-  int nChar, nByte;
-  WCHAR *zUnicode;   /* Unicode version of zUtf8 */
+  int nChar;
+  wchar_t *zUnicode; /* Unicode version of zUtf8 */
+#ifdef UNICODE
+  DWORD dummy;
+#else
   char *zConsole;    /* Console version of zUtf8 */
   int codepage;      /* Console code page */
+#endif
+
+  static int istty[2] = { -1, -1 };
+  if( istty[toStdErr] == -1 ){
+    istty[toStdErr] = _isatty(toStdErr + 1) != 0;
+  }
+  if( !istty[toStdErr] ){
+    /* stdout/stderr is not a console. */
+    return -1;
+  }
 
-  nChar = MultiByteToWideChar(CP_UTF8, 0, zUtf8, -1, NULL, 0);
-  zUnicode = malloc( nChar*sizeof(zUnicode[0]) );
+  nChar = MultiByteToWideChar(CP_UTF8, 0, zUtf8, nByte, NULL, 0);
+  zUnicode = malloc( (nChar + 1) *sizeof(zUnicode[0]) );
   if( zUnicode==0 ){
     return 0;
   }
-  nChar = MultiByteToWideChar(CP_UTF8, 0, zUtf8, -1, zUnicode, nChar);
+  nChar = MultiByteToWideChar(CP_UTF8, 0, zUtf8, nByte, zUnicode, nChar);
   if( nChar==0 ){
     free(zUnicode);
     return 0;
   }
+  zUnicode[nChar] = '\0';
+#ifdef UNICODE
+  WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE - toStdErr), zUnicode, nChar, &dummy, 0);
+#else /* !UNICODE */
   codepage = GetConsoleCP();
-  nByte = WideCharToMultiByte(codepage, 0, zUnicode, -1, 0, 0, 0, 0);
-  zConsole = malloc( nByte );
+  nByte = WideCharToMultiByte(codepage, 0, zUnicode, nChar, 0, 0, 0, 0);
+  zConsole = malloc( nByte + 1);
   if( zConsole==0 ){
     free(zUnicode);
     return 0;
   }
-  nByte = WideCharToMultiByte(codepage, 0, zUnicode, -1, zConsole, nByte, 0, 0);
+  nByte = WideCharToMultiByte(codepage, 0, zUnicode, nChar, zConsole, nByte, 0, 0);
+  zConsole[nByte] = '\0';
   free(zUnicode);
   if( nByte == 0 ){
     free(zConsole);
     zConsole = 0;
+    return 0;
   }
-  return zConsole;
+  fwrite(zConsole, 1, nByte, toStdErr ? stderr : stdout);
+  fflush(toStdErr ? stderr : stdout);
+#endif /* UNICODE */
+  return nChar;
 #else
-  return (char*)zUtf8;  /* No-op on unix */
+  return -1;  /* No-op on unix */
 #endif  
 }
 
 /*
 ** Translate MBCS to UTF8.  Return a pointer.  Call fossil_mbcs_free()

Index: src/http_socket.c
==================================================================
--- src/http_socket.c
+++ src/http_socket.c
@@ -66,11 +66,11 @@
 }
 
 /*
 ** Set the socket error message.
 */
-void socket_set_errmsg(char *zFormat, ...){
+void socket_set_errmsg(const char *zFormat, ...){
   va_list ap;
   socket_clear_errmsg();
   va_start(ap, zFormat);
   socketErrMsg = vmprintf(zFormat, ap);
   va_end(ap);

Index: src/json.c
==================================================================
--- src/json.c
+++ src/json.c
@@ -348,11 +348,11 @@
   if( 0 != rc ){
     cson_value_free( v );
   }
   assert( (0==rc) && "Adding item to GC failed." );
   if(0!=rc){
-    fprintf(stderr,"%s: FATAL: alloc error.\n", fossil_nameofexe())
+    fprintf(stderr,"%s: FATAL: alloc error.\n", g.argv[0])
         /* reminder: allocation error is the only reasonable cause of
            error here, provided g.json.gc.a and v are not NULL.
         */
         ;
     fossil_exit(1)/*not fossil_panic() b/c it might land us somewhere
@@ -1628,11 +1628,11 @@
   if(!resp){
     /* about the only error case here is out-of-memory. DO NOT
        call fossil_panic() here because that calls this function.
     */
     fprintf(stderr, "%s: Fatal error: could not allocate "
-            "response object.\n", fossil_nameofexe());
+            "response object.\n", g.argv[0]);
     fossil_exit(1);
   }
   if( g.isHTTP ){
     if(alsoOutput){
       json_send_response(resp);

Index: src/main.c
==================================================================
--- src/main.c
+++ src/main.c
@@ -331,28 +331,28 @@
     db_close(0);
   }
 }
 
 /*
-** Convert all arguments from mbcs to UTF-8. Then
+** Convert all arguments from mbcs (or unicode) to UTF-8. Then
 ** search g.argv for arguments "--args FILENAME". If found, then
 ** (1) remove the two arguments from g.argv
 ** (2) Read the file FILENAME
 ** (3) Use the contents of FILE to replace the two removed arguments:
 **     (a) Ignore blank lines in the file
 **     (b) Each non-empty line of the file is an argument, except
 **     (c) If the line begins with "-" and contains a space, it is broken
 **         into two arguments at the space.
 */
-static void expand_args_option(int argc, char **argv){
+static void expand_args_option(int argc, void *argv){
   Blob file = empty_blob;   /* Content of the file */
   Blob line = empty_blob;   /* One line of the file */
   unsigned int nLine;       /* Number of lines in the file*/
   unsigned int i, j, k;     /* Loop counters */
   int n;                    /* Number of bytes in one line */
-  char *z;            /* General use string pointer */
-  char **newArgv;     /* New expanded g.argv under construction */
+  char *z;                  /* General use string pointer */
+  char **newArgv;           /* New expanded g.argv under construction */
   char const * zFileName;   /* input file name */
   FILE * zInFile;           /* input FILE */
   int foundBom = -1;        /* -1= not searched yet, 0 = no; 1=yes */
 #ifdef _WIN32
   wchar_t buf[MAX_PATH];
@@ -361,11 +361,15 @@
   g.argc = argc;
   g.argv = argv;
 #ifdef _WIN32
   GetModuleFileNameW(NULL, buf, MAX_PATH);
   g.argv[0] = fossil_unicode_to_utf8(buf);
+#ifdef UNICODE
+  for(i=1; i<g.argc; i++) g.argv[i] = fossil_unicode_to_utf8(g.argv[i]);
+#else
   for(i=1; i<g.argc; i++) g.argv[i] = fossil_mbcs_to_utf8(g.argv[i]);
+#endif
 #endif
   for(i=1; i<g.argc-1; i++){
     z = g.argv[i];
     if( z[0]!='-' ) continue;
     z++;
@@ -430,11 +434,16 @@
 }
 
 /*
 ** This procedure runs first.
 */
-int main(int argc, char **argv){
+#if defined(_WIN32) && defined(UNICODE)
+int wmain(int argc, wchar_t **argv)
+#else
+int main(int argc, char **argv)
+#endif
+{
   const char *zCmdName = "unknown";
   int idx;
   int rc;
 
   sqlite3_config(SQLITE_CONFIG_LOG, fossil_sqlite_log, 0);
@@ -1742,11 +1751,11 @@
 ** See also: cgi, http, winsrv
 */
 void cmd_webserver(void){
   int iPort, mxPort;        /* Range of TCP ports allowed */
   const char *zPort;        /* Value of the --port option */
-  char *zBrowser;           /* Name of web browser program */
+  const char *zBrowser;     /* Name of web browser program */
   char *zBrowserCmd = 0;    /* Command to launch the web browser */
   int isUiCmd;              /* True if command is "ui", not "server' */
   const char *zNotFound;    /* The --notfound option or NULL */
   int flags = 0;            /* Server flags */
 
@@ -1779,11 +1788,11 @@
   /* Unix implementation */
   if( isUiCmd ){
 #if !defined(__DARWIN__) && !defined(__APPLE__) && !defined(__HAIKU__)
     zBrowser = db_get("web-browser", 0);
     if( zBrowser==0 ){
-      static char *azBrowserProg[] = { "xdg-open", "gnome-open", "firefox" };
+      static const char *const azBrowserProg[] = { "xdg-open", "gnome-open", "firefox" };
       int i;
       zBrowser = "echo";
       for(i=0; i<sizeof(azBrowserProg)/sizeof(azBrowserProg[0]); i++){
         if( binaryOnPath(azBrowserProg[i]) ){
           zBrowser = azBrowserProg[i];

Index: src/makeheaders.c
==================================================================
--- src/makeheaders.c
+++ src/makeheaders.c
@@ -1644,11 +1644,11 @@
   pLast = pLast->pNext;
   for(p=pFirst; p && p!=pLast; p=p->pNext){
     if( p->eType==TT_Id ){
       static IdentTable sReserved;
       static int isInit = 0;
-      static char *aWords[] = { "char", "class", 
+      static const char *const aWords[] = { "char", "class",
        "const", "double", "enum", "extern", "EXPORT", "ET_PROC", 
        "float", "int", "long",
        "PRIVATE", "PROTECTED", "PUBLIC",
        "register", "static", "struct", "sizeof", "signed", "typedef", 
        "union", "volatile", "virtual", "void", };
@@ -3253,11 +3253,11 @@
 
 /*
 ** The following text contains a few simple #defines that we want
 ** to be available to every file.
 */
-static char zInit[] = 
+static const char zInit[] =
   "#define INTERFACE 0\n"
   "#define EXPORT_INTERFACE 0\n"
   "#define LOCAL_INTERFACE 0\n"
   "#define EXPORT\n"
   "#define LOCAL static\n"

Index: src/makemake.tcl
==================================================================
--- src/makemake.tcl
+++ src/makemake.tcl
@@ -334,14 +334,13 @@
 #
 
 #### Select one of MinGW, MinGW-64 (32-bit) or MinGW-w64 (64-bit) compilers.
 #    By default, this is an empty string (i.e. use the native compiler).
 #
-PREFIX =
 # PREFIX = mingw32-
 # PREFIX = i686-pc-mingw32-
-# PREFIX = i686-w64-mingw32-
+PREFIX = i686-w64-mingw32-
 # PREFIX = x86_64-w64-mingw32-
 
 #### The toplevel directory of the source tree.  Fossil can be built
 #    in a directory that is separate from the source tree.  Just change
 #    the following to point from the build directory to the src/ folder.
@@ -425,11 +424,11 @@
 #    will run on the target platform.  This is usually the same
 #    as BCC, unless you are cross-compiling.  This C compiler builds
 #    the finished binary for fossil.  The BCC compiler above is used
 #    for building intermediate code-generator tools.
 #
-TCC = $(PREFIX)gcc -Os -Wall -L$(ZLIBDIR) -I$(ZINCDIR)
+TCC = $(PREFIX)gcc -Os -Wall -DUNICODE -D_UNICODE -L$(ZLIBDIR) -I$(ZINCDIR)
 
 #### Compile resources for use in building executables that will run
 #    on the target platform.
 #
 RCC = $(PREFIX)windres -I$(SRCDIR) -I$(ZINCDIR)
@@ -496,15 +495,17 @@
 ifdef FOSSIL_ENABLE_TCL
 LIB += -lnetapi32 -lkernel32 -luser32 -ladvapi32 -lws2_32
 else
 LIB += -lkernel32 -lws2_32
 endif
+
+LIB += -municode
 
 #### Tcl shell for use in running the fossil test suite.  This is only
 #    used for testing.
 #
-TCLSH = tclsh
+TCLSH = tclsh86
 
 #### Nullsoft installer MakeNSIS location
 #
 MAKENSIS = "$(ProgramFiles)\NSIS\MakeNSIS.exe"
 
@@ -894,11 +895,11 @@
 ZLIBDIR = $(MSCDIR)\extra\lib
 ZLIB    = zlib.lib
 
 INCL   = -I. -I$(SRCDIR) -I$B\win\include -I$(MSCDIR)\extra\include -I$(ZINCDIR)
 
-CFLAGS = -nologo -MT -O2
+CFLAGS = -nologo -MT -O2 -DUNICODE -D_UNICODE
 BCC    = $(CC) $(CFLAGS)
 TCC    = $(CC) -c $(CFLAGS) $(MSCDEF) $(SSL) $(INCL)
 LIBS   = $(ZLIB) ws2_32.lib advapi32.lib $(SSLLIB)
 LIBDIR = -LIBPATH:$(MSCDIR)\extra\lib -LIBPATH:$(ZLIBDIR)
 }

Index: src/printf.c
==================================================================
--- src/printf.c
+++ src/printf.c
@@ -814,25 +814,16 @@
 ** 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)
-  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;
+  if( fossil_utf8_to_console(z, strlen(z), toStdErr) >= 0 ){
+    return;
   }
+#endif
   assert( toStdErr==0 || toStdErr==1 );
-  if( istty[toStdErr] ) z = zToFree = fossil_utf8_to_console(z);
   fwrite(z, 1, strlen(z), toStdErr ? stderr : stdout);
-  free(zToFree);
-#else
-  fwrite(z, 1, strlen(z), toStdErr ? stderr : stdout);
-#endif
   fflush(toStdErr ? stderr : stdout);
 }
 
 /*
 ** Write output for user consumption.  If g.cgiOutput is enabled, then

Index: src/rebuild.c
==================================================================
--- src/rebuild.c
+++ src/rebuild.c
@@ -608,11 +608,11 @@
     if( activateWal ){
       db_multi_exec("PRAGMA journal_mode=WAL;");
     }
   }
   if( showStats ){
-    static struct { int idx; const char *zLabel; } aStat[] = {
+    static const struct { int idx; const char *zLabel; } aStat[] = {
        { CFTYPE_ANY,       "Artifacts:" },
        { CFTYPE_MANIFEST,  "Manifests:" },
        { CFTYPE_CLUSTER,   "Clusters:" },
        { CFTYPE_CONTROL,   "Tags:" },
        { CFTYPE_WIKI,      "Wikis:" },
@@ -816,11 +816,11 @@
 
 /*
 ** Recursively read all files from the directory zPath and install
 ** every file read as a new artifact in the repository.
 */
-void recon_read_dir(char *zPath){
+void recon_read_dir(const char *zPath){
   FOSSIL_DIR *d;
   struct fossil_dirent *pEntry;
   Blob aContent; /* content of the just read artifact */
   static int nFileRead = 0;
   void *zUnicodePath;

Index: src/report.c
==================================================================
--- src/report.c
+++ src/report.c
@@ -170,11 +170,11 @@
     case SQLITE_SELECT:
     case SQLITE_FUNCTION: {
       break;
     }
     case SQLITE_READ: {
-      static const char *azAllowed[] = {
+      static const char *const azAllowed[] = {
          "ticket",
          "blob",
          "filename",
          "mlink",
          "plink",

Index: src/shell.c
==================================================================
--- src/shell.c
+++ src/shell.c
@@ -451,11 +451,11 @@
 #define MODE_Insert   5  /* Generate SQL "insert" statements */
 #define MODE_Tcl      6  /* Generate ANSI-C or TCL quoted elements */
 #define MODE_Csv      7  /* Quote strings, numbers are plain */
 #define MODE_Explain  8  /* Like MODE_Column, but do not truncate data */
 
-static const char *modeDescr[] = {
+static const char *const modeDescr[] = {
   "line",
   "column",
   "list",
   "semi",
   "html",
@@ -1381,11 +1381,11 @@
 }
 
 /*
 ** Text of a help message
 */
-static char zHelp[] =
+static const char zHelp[] =
   ".backup ?DB? FILE      Backup DB (default \"main\") to FILE\n"
   ".bail ON|OFF           Stop after hitting an error.  Default OFF\n"
   ".databases             List names and files of attached databases\n"
   ".dump ?TABLE? ...      Dump the database in an SQL text format\n"
   "                         If TABLE specified, only dump tables matching\n"
@@ -1436,11 +1436,11 @@
   ".trace FILE|off        Output each SQL statement as it is run\n"
   ".vfsname ?AUX?         Print the name of the VFS stack\n"
   ".width NUM1 NUM2 ...   Set column widths for \"column\" mode\n"
 ;
 
-static char zTimerHelp[] =
+static const char zTimerHelp[] =
   ".timer ON|OFF          Turn the CPU timer measurement on or off\n"
 ;
 
 /* Forward reference */
 static int process_input(struct callback_data *p, FILE *in);

Index: src/tag.c
==================================================================
--- src/tag.c
+++ src/tag.c
@@ -398,11 +398,11 @@
   if( n==0 ){
     goto tag_cmd_usage;
   }
 
   if( strncmp(g.argv[2],"add",n)==0 ){
-    char *zValue;
+    const char *zValue;
     const char *zDateOvrd = find_option("date-override",0,1);
     const char *zUserOvrd = find_option("user-override",0,1);
     if( g.argc!=5 && g.argc!=6 ){
       usage("add ?--raw? ?--propagate? TAGNAME CHECK-IN ?VALUE?");
     }

Index: src/th.c
==================================================================
--- src/th.c
+++ src/th.c
@@ -2296,11 +2296,11 @@
 **    { } [ ] \ ; ' "
 **
 **    " 0x22
 **
 */
-static unsigned char aCharProp[256] = {
+static const unsigned char aCharProp[256] = {
   0,  0,  0,  0,  0,  0,  0,  0,     0,  1,  1,  1,  1,  1,  0,  0,   /* 0x0. */
   0,  0,  1,  1,  0,  0,  0,  0,     0,  0,  0,  0,  0,  0,  0,  0,   /* 0x1. */
   5,  4, 20,  4,  4,  4,  4,  4,     4,  4,  4,  4,  4,  4,  4,  4,   /* 0x2. */
   6,  6,  6,  6,  6,  6,  6,  6,     6,  6,  4, 20,  4,  4,  4,  4,   /* 0x3. */
   4, 12, 12, 12, 12, 12, 12, 12,    12, 12, 12, 12, 12, 12, 12, 12,   /* 0x4. */

Index: src/timeline.c
==================================================================
--- src/timeline.c
+++ src/timeline.c
@@ -1455,11 +1455,11 @@
 void timeline_cmd(void){
   Stmt q;
   int n, k;
   const char *zCount;
   const char *zType;
-  char *zOrigin;
+  const char *zOrigin;
   char *zDate;
   Blob sql;
   int objid = 0;
   Blob uuid;
   int mode = 0 ;       /* 0:none  1: before  2:after  3:children  4:parents */

Index: src/tkt.c
==================================================================
--- src/tkt.c
+++ src/tkt.c
@@ -26,13 +26,13 @@
 ** The list of database user-defined fields in the TICKET table.
 ** The real table also contains some addition fields for internal
 ** used.  The internal-use fields begin with "tkt_".
 */
 static int nField = 0;
-static char **azField = 0;    /* Names of database fields */
-static char **azValue = 0;    /* Original values */
-static char **azAppend = 0;   /* Value to be appended */
+static const char **azField = 0;    /* Names of database fields */
+static const char **azValue = 0;    /* Original values */
+static const char **azAppend = 0;   /* Value to be appended */
 
 /*
 ** Compare two entries in azField for sorting purposes
 */
 static int nameCmpr(const void *a, const void *b){
@@ -1117,23 +1117,24 @@
         fossil_fatal("empty %s command aborted!",g.argv[2]);
       }
       getAllTicketFields();
       /* read commandline and assign fields in the azValue array */
       while( i<g.argc ){
-        char *zFName;
-        char *zFValue;
+        const char *zFName;
+        const char *zFValue;
         int j;
         int append = 0;
 
         zFName = g.argv[i++];
         if( i==g.argc ){
           fossil_fatal("missing value for '%s'!",zFName);
         }
         zFValue = g.argv[i++];
         if( tktEncoding == tktFossilize ){
-          zFValue=mprintf("%s",zFValue);
-          defossilize(zFValue);
+          char *z = mprintf("%s",zFValue);
+          defossilize(z);
+          zFValue = z;
         }
         append = (zFName[0] == '+');
         if (append){
           zFName++;
         }
@@ -1153,12 +1154,12 @@
       blob_zero(&tktchng);
       /* add the time to the ticket manifest */
       blob_appendf(&tktchng, "D %s\n", zDate);
       /* append defined elements */
       for(i=0; i<nField; i++){
-        char *zValue = 0;
-        char *zPfx;
+        const char *zValue = 0;
+        const char *zPfx;
 
         if (azAppend[i] && azAppend[i][0] ){
           zPfx = " +";
           zValue = azAppend[i];
         } else if( azValue[i] && azValue[i][0] ){

Index: src/translate.c
==================================================================
--- src/translate.c
+++ src/translate.c
@@ -1,7 +1,7 @@
 /*
-** Copyright (c) 2002 D. Richard Hipp
+** Copyright © 2002 D. Richard Hipp
 **
 ** This program is free software; you can redistribute it and/or
 ** modify it under the terms of the Simplified BSD License (also
 ** known as the "2-Clause License" or "FreeBSD License".)
 
@@ -76,17 +76,34 @@
   char c1, c2;          /* Characters used to start a comment */
   int lastWasEq = 0;    /* True if last non-whitespace character was "=" */
   int lastWasComma = 0; /* True if last non-whitespace character was "," */
   char zLine[2000];     /* A single line of input */
   char zOut[4000];      /* The input line translated into appropriate output */
+  int isFirstline = 1;  /* True if this is the first line */
 
   c1 = c2 = '-';
   while( fgets(zLine, sizeof(zLine), in) ){
+    if (isFirstline) {
+      static const char bom[] = { 0xEF, 0xBB, 0xBF };
+      if( memcmp(zLine, bom, 3)==0 ) {
+    	  memmove(zLine, zLine+3, sizeof(zLine)-3);
+      }
+      isFirstline = 0;
+    }
     for(i=0; zLine[i] && isspace(zLine[i]); i++){}
     if( zLine[i]!='@' ){
       if( inPrint || inStr ) end_block(out);
-      fprintf(out,"%s",zLine);
+      for(i=0,j=0; zLine[i]; i++){
+        if (128 <= (unsigned char)zLine[i]) {
+          sprintf(&zOut[j], "\\0x%.2X", zLine[i] & 0xFF);
+          j += 5;
+        } else {
+          zOut[j++] = zLine[i];
+        }
+      }
+      zOut[j] = 0;
+      fprintf(out,"%s",zOut);
                        /* 0123456789 12345 */
       if( strncmp(zLine, "/* @-comment: ", 14)==0 ){
         c1 = zLine[14];
         c2 = zLine[15];
       }
@@ -110,11 +127,16 @@
       for(j=0; zLine[i] && zLine[i]!='\r' && zLine[i]!='\n'; i++){
         if( zLine[i]==c1 && (c2==' ' || zLine[i+1]==c2) ){
            omitline = 1; break; 
         }
         if( zLine[i]=='"' || zLine[i]=='\\' ){ zOut[j++] = '\\'; }
-        zOut[j++] = zLine[i];
+        if (128 <= (unsigned char)zLine[i]) {
+          sprintf(&zOut[j], "\\0x%.2X", zLine[i] & 0xFF);
+          j += 5;
+        } else {
+          zOut[j++] = zLine[i];
+        }
       }
       while( j>0 && isspace(zOut[j-1]) ){ j--; }
       zOut[j] = 0;
       if( j<=0 && omitline ){
         fprintf(out,"\n");
@@ -134,11 +156,16 @@
       i++;
       if( isspace(zLine[i]) ){ i++; }
       indent = i;
       for(j=0; zLine[i] && zLine[i]!='\r' && zLine[i]!='\n'; i++){
         if( zLine[i]=='"' || zLine[i]=='\\' ){ zOut[j++] = '\\'; }
-        zOut[j++] = zLine[i];
+        if (128 <= (unsigned char)zLine[i]) {
+          sprintf(&zOut[j], "\\0x%.2X", zLine[i] & 0xFF);
+          j += 5;
+        } else {
+          zOut[j++] = zLine[i];
+        }
         if( zLine[i]!='%' || zLine[i+1]=='%' || zLine[i+1]==0 ) continue;
         for(nC=1; zLine[i+nC] && zLine[i+nC]!='('; nC++){}
         if( zLine[i+nC]!='(' || !isalpha(zLine[i+nC-1]) ) continue;
         while( --nC ) zOut[j++] = zLine[++i];
         zArg[nArg++] = ',';

Index: src/wiki.c
==================================================================
--- src/wiki.c
+++ src/wiki.c
@@ -963,11 +963,11 @@
     manifest_destroy(pWiki);
     return;
   }else
   if( strncmp(g.argv[2],"commit",n)==0
       || strncmp(g.argv[2],"create",n)==0 ){
-    char *zPageName;
+    const char *zPageName;
     Blob content;
     if( g.argc!=4 && g.argc!=5 ){
       usage("commit PAGENAME ?FILE?");
     }
     zPageName = g.argv[3];

Index: src/winhttp.c
==================================================================
--- src/winhttp.c
+++ src/winhttp.c
@@ -129,14 +129,20 @@
   file_delete(zRequestFName);
   file_delete(zReplyFName);
   free(p);
 }
 
+#if !defined(UNICODE)
+#  define fossil_unicode_to_utf8 fossil_mbcs_to_utf8
+#  define fossil_utf8_to_unicode fossil_utf8_to_mbcs
+#endif
+
 /*
 ** Start a listening socket and process incoming HTTP requests on
 ** that socket.
 */
+
 void win32_http_server(
   int mnPort, int mxPort,   /* Range of allowed TCP port numbers */
   const char *zBrowser,     /* Command to launch browser.  (Or NULL) */
   const char *zStopper,     /* Stop server when this file is exists (Or NULL) */
   const char *zNotFound,    /* The --notfound option, or NULL */
@@ -146,11 +152,11 @@
   SOCKET s = INVALID_SOCKET;
   SOCKADDR_IN addr;
   int idCnt = 0;
   int iPort = mnPort;
   Blob options;
-  char zTmpPath[MAX_PATH];
+  TCHAR zTmpPath[MAX_PATH];
 
   if( zStopper ) file_delete(zStopper);
   blob_zero(&options);
   if( zNotFound ){
     blob_appendf(&options, " --notfound %s", zNotFound);
@@ -194,11 +200,11 @@
     }
   }
   if( !GetTempPath(MAX_PATH, zTmpPath) ){
     fossil_fatal("unable to get path to the temporary directory.");
   }
-  zTempPrefix = mprintf("%sfossil_server_P%d_", fossil_mbcs_to_utf8(zTmpPath), iPort);
+  zTempPrefix = mprintf("%sfossil_server_P%d_", fossil_unicode_to_utf8(zTmpPath), iPort);
   fossil_print("Listening for HTTP requests on TCP port %d\n", iPort);
   if( zBrowser ){
     zBrowser = mprintf(zBrowser, iPort);
     fossil_print("Launch webbrowser: %s\n", zBrowser);
     fossil_system(zBrowser);
@@ -249,11 +255,11 @@
 struct HttpService {
   int port;                 /* Port on which the http server should run */
   const char *zNotFound;    /* The --notfound option, or NULL */
   int flags;                /* One or more HTTP_SERVER_ flags */
   int isRunningAsService;   /* Are we running as a service ? */
-  const char *zServiceName; /* Name of the service */
+  const TCHAR *zServiceName;/* Name of the service */
   SOCKET s;                 /* Socket on which the http server listens */
 };
 
 /*
 ** Variables used for running as windows service.
@@ -298,11 +304,11 @@
              0,
              NULL
            );
   }
   if( nMsg ){
-    zMsg = fossil_mbcs_to_utf8(tmp);
+    zMsg = fossil_unicode_to_utf8(tmp);
   }else{
     fossil_fatal("unable to get system error message.");
   }
   if( tmp ){
     LocalFree((HLOCAL) tmp);
@@ -384,11 +390,11 @@
   if( argc>0 ){
     hsData.zServiceName = argv[0];
   }
 
   /* Register the service control handler function */
-  sshStatusHandle = RegisterServiceCtrlHandler("", win32_http_service_ctrl);
+  sshStatusHandle = RegisterServiceCtrlHandler(TEXT(""), win32_http_service_ctrl);
   if( !sshStatusHandle ){
     win32_report_service_status(SERVICE_STOPPED, NO_ERROR, 0);
     return;
   }
 
@@ -429,11 +435,11 @@
   const char *zNotFound,    /* The --notfound option, or NULL */
   int flags                 /* One or more HTTP_SERVER_ flags */
 ){
   /* Define the service table. */
   SERVICE_TABLE_ENTRY ServiceTable[] =
-    {{"", (LPSERVICE_MAIN_FUNCTION)win32_http_service_main}, {NULL, NULL}};
+    {{TEXT(""), (LPSERVICE_MAIN_FUNCTION)win32_http_service_main}, {NULL, NULL}};
   
   /* Initialize the HttpService structure. */
   hsData.port = nPort;
   hsData.zNotFound = zNotFound;
   hsData.flags = flags;
@@ -447,11 +453,12 @@
     }
   }
   return 0;
 }
 
-/*
+#ifdef _WIN32
+/* dupe ifdef needed for mkindex
 ** COMMAND: winsrv*
 ** Usage: fossil winsrv METHOD ?SERVICE-NAME? ?OPTIONS?
 **
 ** Where METHOD is one of: create delete show start stop.
 **
@@ -565,11 +572,11 @@
 
   if( strncmp(zMethod, "create", n)==0 ){
     SC_HANDLE hScm;
     SC_HANDLE hSvc;
     SERVICE_DESCRIPTION
-      svcDescr = {"Fossil - Distributed Software Configuration Management"};
+      svcDescr = {TEXT("Fossil - Distributed Software Configuration Management")};
     char *zErrFmt = "unable to create service '%s': %s";
     DWORD dwStartType = SERVICE_DEMAND_START;
     const char *zDisplay    = find_option("display", "D", 1);
     const char *zStart      = find_option("start", "S", 1);
     const char *zUsername   = find_option("username", "U", 1);
@@ -624,22 +631,22 @@
     /* Create the service. */
     hScm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
     if( !hScm ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
     hSvc = CreateService(
              hScm,                                    /* Handle to the SCM */
-             fossil_utf8_to_mbcs(zSvcName),           /* Name of the service */
-             fossil_utf8_to_mbcs(zDisplay),           /* Display name */
+             fossil_utf8_to_unicode(zSvcName),           /* Name of the service */
+             fossil_utf8_to_unicode(zDisplay),           /* Display name */
              SERVICE_ALL_ACCESS,                      /* Desired access */
              SERVICE_WIN32_OWN_PROCESS,               /* Service type */
              dwStartType,                             /* Start type */
              SERVICE_ERROR_NORMAL,                    /* Error control */
-             fossil_utf8_to_mbcs(blob_str(&binPath)), /* Binary path */
+             fossil_utf8_to_unicode(blob_str(&binPath)), /* Binary path */
              NULL,                                    /* Load ordering group */
              NULL,                                    /* Tag value */
              NULL,                                    /* Service dependencies */
-             fossil_utf8_to_mbcs(zUsername),          /* Service account */
-             fossil_utf8_to_mbcs(zPassword)           /* Account password */
+             fossil_utf8_to_unicode(zUsername),          /* Service account */
+             fossil_utf8_to_unicode(zPassword)           /* Account password */
            );
     if( !hSvc ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
     /* Set the service description. */
     ChangeServiceConfig2(hSvc, SERVICE_CONFIG_DESCRIPTION, &svcDescr);
     fossil_print("Service '%s' successfully created.\n", zSvcName);
@@ -658,11 +665,11 @@
     }else if( g.argc>4 ){
       fossil_fatal("to much arguments for delete method.");
     }
     hScm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
     if( !hScm ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
-    hSvc = OpenService(hScm, fossil_utf8_to_mbcs(zSvcName), SERVICE_ALL_ACCESS);
+    hSvc = OpenService(hScm, fossil_utf8_to_unicode(zSvcName), SERVICE_ALL_ACCESS);
     if( !hSvc ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
     QueryServiceStatus(hSvc, &sstat);
     if( sstat.dwCurrentState!=SERVICE_STOPPED ){
       fossil_print("Stopping service '%s'", zSvcName);
       if( sstat.dwCurrentState!=SERVICE_STOP_PENDING ){
@@ -695,28 +702,28 @@
     SERVICE_STATUS sstat;
     LPQUERY_SERVICE_CONFIG pSvcConfig;
     LPSERVICE_DESCRIPTION pSvcDescr;
     BOOL bStatus;
     DWORD nRequired;
-    char *zErrFmt = "unable to show service '%s': %s";
-    static const char *zSvcTypes[] = {
+    const char *zErrFmt = "unable to show service '%s': %s";
+    static const char *const zSvcTypes[] = {
       "Driver service",
       "File system driver service",
       "Service runs in its own process",
       "Service shares a process with other services",
       "Service can interact with the desktop"
     };
     const char *zSvcType = "";
-    static char *zSvcStartTypes[] = {
+    static const char *const zSvcStartTypes[] = {
       "Started by the system loader",
       "Started by the IoInitSystem function",
       "Started automatically by the service control manager",
       "Started manually",
       "Service cannot be started"
     };
     const char *zSvcStartType = "";
-    static const char *zSvcStates[] = {
+    static const char *const zSvcStates[] = {
       "Stopped", "Starting", "Stopping", "Running",
       "Continue pending", "Pause pending", "Paused"
     };
     const char *zSvcState = "";
 
@@ -726,11 +733,11 @@
     }else if( g.argc>4 ){
       fossil_fatal("to much arguments for show method.");
     }
     hScm = OpenSCManager(NULL, NULL, GENERIC_READ);
     if( !hScm ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
-    hSvc = OpenService(hScm, fossil_utf8_to_mbcs(zSvcName), GENERIC_READ);
+    hSvc = OpenService(hScm, fossil_utf8_to_unicode(zSvcName), GENERIC_READ);
     if( !hSvc ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
     /* Get the service configuration */
     bStatus = QueryServiceConfig(hSvc, NULL, 0, &nRequired);
     if( !bStatus && GetLastError()!=ERROR_INSUFFICIENT_BUFFER ){
       fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
@@ -778,19 +785,19 @@
       case SERVICE_PAUSED:           zSvcState = zSvcStates[6]; break;
     }
     /* Print service information to terminal */
     fossil_print("Service name .......: %s\n", zSvcName);
     fossil_print("Display name .......: %s\n",
-                 fossil_mbcs_to_utf8(pSvcConfig->lpDisplayName));
+                 fossil_unicode_to_utf8(pSvcConfig->lpDisplayName));
     fossil_print("Service description : %s\n",
-                 fossil_mbcs_to_utf8(pSvcDescr->lpDescription));
+                 fossil_unicode_to_utf8(pSvcDescr->lpDescription));
     fossil_print("Service type .......: %s.\n", zSvcType);
     fossil_print("Service start type .: %s.\n", zSvcStartType);
     fossil_print("Binary path name ...: %s\n",
-                 fossil_mbcs_to_utf8(pSvcConfig->lpBinaryPathName));
+                 fossil_unicode_to_utf8(pSvcConfig->lpBinaryPathName));
     fossil_print("Service username ...: %s\n",
-                 fossil_mbcs_to_utf8(pSvcConfig->lpServiceStartName));
+                 fossil_unicode_to_utf8(pSvcConfig->lpServiceStartName));
     fossil_print("Current state ......: %s.\n", zSvcState);
     /* Cleanup */
     fossil_free(pSvcConfig);
     fossil_free(pSvcDescr);
     CloseServiceHandle(hSvc);
@@ -808,11 +815,11 @@
     }else if( g.argc>4 ){
       fossil_fatal("to much arguments for start method.");
     }
     hScm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
     if( !hScm ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
-    hSvc = OpenService(hScm, fossil_utf8_to_mbcs(zSvcName), SERVICE_ALL_ACCESS);
+    hSvc = OpenService(hScm, fossil_utf8_to_unicode(zSvcName), SERVICE_ALL_ACCESS);
     if( !hSvc ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
     QueryServiceStatus(hSvc, &sstat);
     if( sstat.dwCurrentState!=SERVICE_RUNNING ){
       fossil_print("Starting service '%s'", zSvcName);
       if( sstat.dwCurrentState!=SERVICE_START_PENDING ){
@@ -844,11 +851,11 @@
     }else if( g.argc>4 ){
       fossil_fatal("to much arguments for stop method.");
     }
     hScm = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
     if( !hScm ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
-    hSvc = OpenService(hScm, fossil_utf8_to_mbcs(zSvcName), SERVICE_ALL_ACCESS);
+    hSvc = OpenService(hScm, fossil_utf8_to_unicode(zSvcName), SERVICE_ALL_ACCESS);
     if( !hSvc ) fossil_fatal(zErrFmt, zSvcName, win32_get_last_errmsg());
     QueryServiceStatus(hSvc, &sstat);
     if( sstat.dwCurrentState!=SERVICE_STOPPED ){
       fossil_print("Stopping service '%s'", zSvcName);
       if( sstat.dwCurrentState!=SERVICE_STOP_PENDING ){
@@ -872,7 +879,8 @@
     fossil_fatal("METHOD should be one of:"
                  " create delete show start stop");
   }
   return;
 }
+#endif /* _WIN32 */
 
 #endif /* _WIN32  -- This code is for win32 only */

Index: src/xfer.c
==================================================================
--- src/xfer.c
+++ src/xfer.c
@@ -270,11 +270,11 @@
   int rid,                /* record id of the file to send */
   int isPrivate,          /* True if rid is a private artifact */
   Blob *pContent,         /* The content of the file to send */
   Blob *pUuid             /* The UUID of the file to send */
 ){
-  static const char *azQuery[] = {
+  static const char *const azQuery[] = {
     "SELECT pid FROM plink x"
     " WHERE cid=%d"
     "   AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=pid)"
     "   AND NOT EXISTS(SELECT 1 FROM plink y"
                       " WHERE y.pid=x.cid AND y.cid=x.pid)",

ADDED   test/世界/界世.txt
Index: test/世界/界世.txt
==================================================================
--- test/世界/界世.txt
+++ test/世界/界世.txt
@@ -0,0 +1,1 @@
+Just some text

Index: win/Makefile.mingw
==================================================================
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -13,14 +13,13 @@
 #
 
 #### Select one of MinGW, MinGW-64 (32-bit) or MinGW-w64 (64-bit) compilers.
 #    By default, this is an empty string (i.e. use the native compiler).
 #
-PREFIX =
 # PREFIX = mingw32-
 # PREFIX = i686-pc-mingw32-
-# PREFIX = i686-w64-mingw32-
+PREFIX = i686-w64-mingw32-
 # PREFIX = x86_64-w64-mingw32-
 
 #### The toplevel directory of the source tree.  Fossil can be built
 #    in a directory that is separate from the source tree.  Just change
 #    the following to point from the build directory to the src/ folder.
@@ -104,11 +103,11 @@
 #    will run on the target platform.  This is usually the same
 #    as BCC, unless you are cross-compiling.  This C compiler builds
 #    the finished binary for fossil.  The BCC compiler above is used
 #    for building intermediate code-generator tools.
 #
-TCC = $(PREFIX)gcc -Os -Wall -L$(ZLIBDIR) -I$(ZINCDIR)
+TCC = $(PREFIX)gcc -Os -Wall -DUNICODE -D_UNICODE -L$(ZLIBDIR) -I$(ZINCDIR)
 
 #### Compile resources for use in building executables that will run
 #    on the target platform.
 #
 RCC = $(PREFIX)windres -I$(SRCDIR) -I$(ZINCDIR)
@@ -175,15 +174,17 @@
 ifdef FOSSIL_ENABLE_TCL
 LIB += -lnetapi32 -lkernel32 -luser32 -ladvapi32 -lws2_32
 else
 LIB += -lkernel32 -lws2_32
 endif
+
+LIB += -municode
 
 #### Tcl shell for use in running the fossil test suite.  This is only
 #    used for testing.
 #
-TCLSH = tclsh
+TCLSH = tclsh86
 
 #### Nullsoft installer MakeNSIS location
 #
 MAKENSIS = "$(ProgramFiles)\NSIS\MakeNSIS.exe"
 

Index: win/Makefile.mingw.mistachkin
==================================================================
--- win/Makefile.mingw.mistachkin
+++ win/Makefile.mingw.mistachkin
@@ -13,14 +13,13 @@
 #
 
 #### Select one of MinGW, MinGW-64 (32-bit) or MinGW-w64 (64-bit) compilers.
 #    By default, this is an empty string (i.e. use the native compiler).
 #
-PREFIX =
 # PREFIX = mingw32-
 # PREFIX = i686-pc-mingw32-
-# PREFIX = i686-w64-mingw32-
+PREFIX = i686-w64-mingw32-
 # PREFIX = x86_64-w64-mingw32-
 
 #### The toplevel directory of the source tree.  Fossil can be built
 #    in a directory that is separate from the source tree.  Just change
 #    the following to point from the build directory to the src/ folder.
@@ -104,11 +103,11 @@
 #    will run on the target platform.  This is usually the same
 #    as BCC, unless you are cross-compiling.  This C compiler builds
 #    the finished binary for fossil.  The BCC compiler above is used
 #    for building intermediate code-generator tools.
 #
-TCC = $(PREFIX)gcc -Os -Wall -L$(ZLIBDIR) -I$(ZINCDIR)
+TCC = $(PREFIX)gcc -Os -Wall -DUNICODE -D_UNICODE -L$(ZLIBDIR) -I$(ZINCDIR)
 
 #### Compile resources for use in building executables that will run
 #    on the target platform.
 #
 RCC = $(PREFIX)windres -I$(SRCDIR) -I$(ZINCDIR)
@@ -175,15 +174,17 @@
 ifdef FOSSIL_ENABLE_TCL
 LIB += -lnetapi32 -lkernel32 -luser32 -ladvapi32 -lws2_32
 else
 LIB += -lkernel32 -lws2_32
 endif
+
+LIB += -municode
 
 #### Tcl shell for use in running the fossil test suite.  This is only
 #    used for testing.
 #
-TCLSH = tclsh
+TCLSH = tclsh86
 
 #### Nullsoft installer MakeNSIS location
 #
 MAKENSIS = "$(ProgramFiles)\NSIS\MakeNSIS.exe"
 

Index: win/Makefile.msc
==================================================================
--- win/Makefile.msc
+++ win/Makefile.msc
@@ -32,11 +32,11 @@
 ZLIBDIR = $(MSCDIR)\extra\lib
 ZLIB    = zlib.lib
 
 INCL   = -I. -I$(SRCDIR) -I$B\win\include -I$(MSCDIR)\extra\include -I$(ZINCDIR)
 
-CFLAGS = -nologo -MT -O2
+CFLAGS = -nologo -MT -O2 -DUNICODE -D_UNICODE
 BCC    = $(CC) $(CFLAGS)
 TCC    = $(CC) -c $(CFLAGS) $(MSCDEF) $(SSL) $(INCL)
 LIBS   = $(ZLIB) ws2_32.lib advapi32.lib $(SSLLIB)
 LIBDIR = -LIBPATH:$(MSCDIR)\extra\lib -LIBPATH:$(ZLIBDIR)