summaryrefslogtreecommitdiff
path: root/src/fl_call_main.c
diff options
context:
space:
mode:
authorMatthias Melcher <fltk@matthiasm.com>2008-09-10 23:56:49 +0000
committerMatthias Melcher <fltk@matthiasm.com>2008-09-10 23:56:49 +0000
commitb6bde2e4569aa617c8a6af64947c688c624ed7f8 (patch)
tree010d15843eb7d4faf7cd1b0cd44d5b9c00462a83 /src/fl_call_main.c
parentdfb50e85292687561927610e689eb5ab30d0ba26 (diff)
Merging the UTF8 patch, consisting of O'ksi'd s original 1.1.6 patch and additions by Ian. PLEASE BE AWARE that the patch in its current incarnation is a regression in many aspects and further work is required before we can announce Unicode support.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6212 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/fl_call_main.c')
-rw-r--r--src/fl_call_main.c44
1 files changed, 42 insertions, 2 deletions
diff --git a/src/fl_call_main.c b/src/fl_call_main.c
index 2b61b62e9..c1ed058dd 100644
--- a/src/fl_call_main.c
+++ b/src/fl_call_main.c
@@ -51,6 +51,7 @@
# include <windows.h>
# include <stdio.h>
# include <stdlib.h>
+#include <FL/fl_utf8.H>
# ifdef __MWERKS__
# include <crtl.h>
@@ -63,9 +64,26 @@ extern int main(int, char *[]);
# define __argv _argv
# endif /* BORLAND5 */
+//static int mbcs2utf(const char *s, int l, char *dst, unsigned dstlen)
+static int mbcs2utf(const char *s, int l, char *dst)
+{
+ static xchar *mbwbuf;
+ unsigned dstlen = 0;
+ if (!s) return 0;
+ dstlen = (l * 6) + 6;
+ mbwbuf = (xchar*)malloc(dstlen * sizeof(xchar));
+ l = mbstowcs(mbwbuf, s, l);
+//l = fl_unicode2utf(mbwbuf, l, dst);
+ l = fl_utf8fromwc(dst, dstlen, mbwbuf, l);
+ dst[l] = 0;
+ free(mbwbuf);
+ return l;
+}
+
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow) {
- int rc;
+ int rc, i;
+ char **ar;
# ifdef _DEBUG
/*
@@ -84,8 +102,30 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
freopen("conout$", "w", stderr);
# endif /* _DEBUG */
+ ar = (char**) malloc(sizeof(char*) * (__argc + 1));
+ i = 0;
+ while (i < __argc) {
+ int l;
+ unsigned dstlen;
+ if (__wargv ) {
+ for (l = 0; __wargv[i] && __wargv[i][l]; l++) {}; // is this just wstrlen???
+ dstlen = (l * 5) + 1;
+ ar[i] = (char*) malloc(dstlen);
+// ar[i][fl_unicode2utf(__wargv[i], l, ar[i])] = 0;
+ dstlen = fl_utf8fromwc(ar[i], dstlen, __wargv[i], l);
+ ar[i][dstlen] = 0;
+ } else {
+ for (l = 0; __argv[i] && __argv[i][l]; l++) {};
+ dstlen = (l * 5) + 1;
+ ar[i] = (char*) malloc(dstlen);
+// ar[i][mbcs2utf(__argv[i], l, ar[i], dstlen)] = 0;
+ ar[i][mbcs2utf(__argv[i], l, ar[i])] = 0;
+ }
+ i++;
+ }
+ ar[__argc] = 0;
/* Run the standard main entry point function... */
- rc = main(__argc, __argv);
+ rc = main(__argc, ar);
# ifdef _DEBUG
fclose(stdin);