Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/sqlite/blob/master/tool/winmain.c # sqlite [Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `sqlite / tool / winmain.c` 79 lines ยท 2337 bytes Raw Blame History 1 /* 2 ** 2025-12-26 3 ** 4 ** The author disclaims copyright to this source code. In place of 5 ** a legal notice, here is a blessing: 6 ** 7 ** May you do good and not evil. 8 ** May you find forgiveness for yourself and forgive others. 9 ** May you share freely, never taking more than you give. 10 ** 11 ************************************************************************* 12 ** 13 ** This file implements a substitute process entry point for windows 14 ** that correctly interprets command-line arguments as UTF-8. This is 15 ** a work-around for the (unfixed) Windows bug known as "WorstFit" and 16 ** described at: 17 ** 18 ** * https://news.ycombinator.com/item?id=`42647101` 19 ** 20 ** USAGE: 21 ** 22 ** If you have a command-line program coded to C-language standard in which 23 ** the entry point is: 24 ** 25 ** int main(int argc, char **argv){...} 26 ** 27 ** That does not work on Windows if there are non-ASCII characters on the 28 ** command line. Programs are expected to use an alternative entry point: 29 ** 30 ** int wmain(int wargc, wchar_t **wargv){...} 31 ** 32 ** This file implements _wmain() but then converts all of the wargv elements 33 ** to UTF-8 and passes them off to utf8_main(). 34 ** 35 ** So, a command-line tool that implements the standard entry point can be 36 ** modified by adding the following lines just prior to main(): 37 ** 38 ** #ifdef _WIN32 39 ** #define main utf8_main 40 ** #endif 41 ** 42 ** Then, include this file in the list of files that implement the program, 43 ** and the program will work correctly, even on Windows. 44 */ 45 #include 46 #include 47 48 extern int utf8_main(int,char**); 49 int wmain(int argc, wchar_t **wargv){ 50 int rc, i; 51 char **argv = malloc( sizeof(char*) * (argc+1) ); 52 char **orig = argv; 53 if( argv==0 ){ 54 fprintf(stderr, "malloc failed\n"); 55 exit(1); 56 } 57 for(i=0; i