aboutsummaryrefslogtreecommitdiff
path: root/src/node_main.cc
diff options
context:
space:
mode:
authorBert Belder <bertbelder@gmail.com>2012-02-16 20:20:07 +0100
committerBert Belder <bertbelder@gmail.com>2012-02-16 20:58:45 +0100
commitd52f5020cecc16349cce902e9f869d33a9213752 (patch)
tree269a9b2146501724b8df360eee290886734e29bc /src/node_main.cc
parent9364699be194cf9175d1bc421050b17ac9875447 (diff)
downloadandroid-node-v8-d52f5020cecc16349cce902e9f869d33a9213752.tar.gz
android-node-v8-d52f5020cecc16349cce902e9f869d33a9213752.tar.bz2
android-node-v8-d52f5020cecc16349cce902e9f869d33a9213752.zip
Windows: another attempt to support unicode argv
Diffstat (limited to 'src/node_main.cc')
-rw-r--r--src/node_main.cc41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/node_main.cc b/src/node_main.cc
index 3100149868..dba8b69203 100644
--- a/src/node_main.cc
+++ b/src/node_main.cc
@@ -21,6 +21,47 @@
#include <node.h>
+#ifdef _WIN32
+int wmain(int argc, wchar_t *wargv[]) {
+ // Convert argv to to UTF8
+ char** argv = new char*[argc];
+ for (int i = 0; i < argc; i++) {
+ // Compute the size of the required buffer
+ DWORD size = WideCharToMultiByte(CP_UTF8,
+ 0,
+ wargv[i],
+ -1,
+ NULL,
+ 0,
+ NULL,
+ NULL);
+ if (size == 0) {
+ // This should never happen.
+ fprintf(stderr, "Could not convert arguments to utf8.");
+ exit(1);
+ }
+ // Do the actual conversion
+ argv[i] = new char[size];
+ DWORD result = WideCharToMultiByte(CP_UTF8,
+ 0,
+ wargv[i],
+ -1,
+ argv[i],
+ size,
+ NULL,
+ NULL);
+ if (result == 0) {
+ // This should never happen.
+ fprintf(stderr, "Could not convert arguments to utf8.");
+ exit(1);
+ }
+ }
+ // Now that conversion is done, we can finally start.
+ return node::Start(argc, argv);
+}
+#else
+// UNIX
int main(int argc, char *argv[]) {
return node::Start(argc, argv);
}
+#endif