File tree Expand file tree Collapse file tree 2 files changed +42
-0
lines changed
Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change 160160 'FD_SETSIZE=1024' ,
161161 # we need to use node's preferred "win32" rather than gyp's preferred "win"
162162 'PLATFORM="win32"' ,
163+ '_UNICODE=1' ,
163164 ],
164165 'libraries' : [ '-lpsapi.lib' ]
165166 },{ # POSIX
Original file line number Diff line number Diff line change 2121
2222#include < node.h>
2323
24+ #ifdef _WIN32
25+ int wmain (int argc, wchar_t *wargv[]) {
26+ // Convert argv to to UTF8
27+ char ** argv = new char *[argc];
28+ for (int i = 0 ; i < argc; i++) {
29+ // Compute the size of the required buffer
30+ DWORD size = WideCharToMultiByte (CP_UTF8,
31+ 0 ,
32+ wargv[i],
33+ -1 ,
34+ NULL ,
35+ 0 ,
36+ NULL ,
37+ NULL );
38+ if (size == 0 ) {
39+ // This should never happen.
40+ fprintf (stderr, " Could not convert arguments to utf8." );
41+ exit (1 );
42+ }
43+ // Do the actual conversion
44+ argv[i] = new char [size];
45+ DWORD result = WideCharToMultiByte (CP_UTF8,
46+ 0 ,
47+ wargv[i],
48+ -1 ,
49+ argv[i],
50+ size,
51+ NULL ,
52+ NULL );
53+ if (result == 0 ) {
54+ // This should never happen.
55+ fprintf (stderr, " Could not convert arguments to utf8." );
56+ exit (1 );
57+ }
58+ }
59+ // Now that conversion is done, we can finally start.
60+ return node::Start (argc, argv);
61+ }
62+ #else
63+ // UNIX
2464int main (int argc, char *argv[]) {
2565 return node::Start (argc, argv);
2666}
67+ #endif
You can’t perform that action at this time.
0 commit comments