summaryrefslogtreecommitdiff
path: root/src/xutf8/utils/convert_map.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/xutf8/utils/convert_map.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/xutf8/utils/convert_map.c')
-rw-r--r--src/xutf8/utils/convert_map.c174
1 files changed, 174 insertions, 0 deletions
diff --git a/src/xutf8/utils/convert_map.c b/src/xutf8/utils/convert_map.c
new file mode 100644
index 000000000..9e4a23e10
--- /dev/null
+++ b/src/xutf8/utils/convert_map.c
@@ -0,0 +1,174 @@
+/******************************************************************************* * $Id: $
+ *
+ * read the http://www.unicode.org/Public/MAPPINGS/ and create something
+ * usable in C.
+ *
+ * Copyright (c) 2000 O'ksi'D
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Author : Jean-Marc Lienher ( http://oksid.ch )
+ *
+ ******************************************************************************/
+
+#include <wchar.h>
+#include <stdio.h>
+
+char buffer[1000000];
+
+int JIS0208(unsigned char * ptr)
+{
+ int i = 0;
+ unsigned int fmap;
+ unsigned int ucs;
+ while(*ptr != '\t') { ptr++; i++; }
+ ptr++; i++; *(ptr+6) = '\0';
+ fmap = (unsigned int)strtoul(ptr, NULL, 16);
+ while(*ptr != '\0') { ptr++; i++; }
+ i++; ptr++; *(ptr+6) = '\0';
+ ucs = (unsigned int)strtoul(ptr, NULL, 16);
+ if (ucs) printf("/* U+%04X */ 0x%02X, 0x%02X,\n", ucs,
+ (fmap & 0xFF00) >> 8, fmap & 0xFF);
+ while(*ptr != '\0') { ptr++; i++; }
+ i++; ptr++;
+ while(*ptr != '\n') { ptr++; i++; }
+ i++;
+ return i;
+}
+
+int JIS0201(unsigned char * ptr)
+{
+ int i = 0;
+ unsigned int fmap;
+ unsigned int ucs;
+ *(ptr+4) = '\0';
+ fmap = (unsigned int)strtoul(ptr, NULL, 16);
+ while(*ptr != '\0') { ptr++; i++; }
+ i++; ptr++; *(ptr+6) = '\0';
+ ucs = (unsigned int)strtoul(ptr, NULL, 16);
+ if (*(ptr + 1) != 'x') {
+ printf("/* EOF */\n");
+ abort();
+ }
+ if (ucs) printf("/* U+%04X */ 0x%02X,\n", ucs, (unsigned char)fmap);
+ while(*ptr != '\0') { ptr++; i++; }
+ i++; ptr++;
+ while(*ptr != '\n') { ptr++; i++; }
+ i++;
+ return i;
+}
+
+int ADOBE(unsigned char * ptr)
+{
+ int i = 0;
+ unsigned int fmap;
+ unsigned int ucs;
+ *(ptr+4) = '\0';
+ ucs = (unsigned int)strtoul(ptr, NULL, 16);
+ while(*ptr != '\0') { ptr++; i++; }
+ i++; ptr++; *(ptr+2) = '\0';
+ fmap = (unsigned int)strtoul(ptr, NULL, 16);
+ if (fmap < 1) {
+ printf("/* EOF */\n");
+ abort();
+ }
+ if (ucs) printf("/* U+%04X */ 0x%02X,\n", ucs, (unsigned char)fmap);
+ while(*ptr != '\0') { ptr++; i++; }
+ i++; ptr++;
+ while(*ptr != '\n') { ptr++; i++; }
+ i++;
+ return i;
+}
+
+
+int JIS0212(unsigned char * ptr)
+{
+ int i = 0;
+ unsigned int fmap;
+ unsigned int ucs;
+ *(ptr+6) = '\0';
+ fmap = (unsigned int)strtoul(ptr, NULL, 16);
+ ptr += 7;
+ i += 7;
+ while(*ptr == ' ') { ptr++; i++; }
+ //i++; ptr++;
+ *(ptr+6) = '\0';
+ ucs = (unsigned int)strtoul(ptr, NULL, 16);
+ if (*(ptr + 1) != 'x') {
+ printf("/* EOF */\n");
+ abort();
+ }
+ if (ucs) printf("/* U+%04X */ 0x%02X, 0x%02X,\n", ucs,
+ (fmap & 0xFF00) >> 8, fmap & 0xFF);
+ while(*ptr != '\0') { ptr++; i++; }
+ i++; ptr++;
+ while(*ptr != '\n') { ptr++; i++; }
+ i++;
+ return i;
+}
+
+int main(int argc, char **argv)
+{
+ char buf[80];
+ int len;
+ int i;
+ unsigned char *ptr;
+ size_t nb;
+ len = fread(buffer, 1, 1000000, stdin);
+
+ buffer[len] = '\0';
+ ptr = (unsigned char *)buffer;
+ while (*ptr !='\n') {ptr++; len--;};
+ ptr++; len--;
+ while (*ptr == '#') {
+ while (*ptr !='\n') {
+ ptr++;
+ len--;
+ }
+ ptr++;
+ len--;
+ }
+
+
+ while (len > 0) {
+ nb = 0;
+ if (!strcmp("jisx0208.1983-0", argv[1])) {
+ nb = JIS0208(ptr);
+ } else if (!strcmp("jisx0201.1976-0", argv[1])) {
+ nb = JIS0201(ptr);
+ } else if (!strcmp("jisx0212.1990-0", argv[1])) {
+ nb = JIS0212(ptr);
+ } else if (!strcmp("gb2312.1980-0", argv[1])) {
+ nb = JIS0212(ptr);
+ } else if (!strcmp("ksc5601.1987-0", argv[1])) {
+ nb = JIS0212(ptr);
+ } else if (!strcmp("big5-0", argv[1])) {
+ nb = JIS0212(ptr);
+ } else if (!strncmp("iso8859", argv[1], 7)) {
+ nb = JIS0201(ptr);
+ } else if (!strcmp("koi8-1", argv[1])) {
+ nb = JIS0201(ptr);
+ } else if (!strcmp("dingbats", argv[1]) ||
+ !strcmp("symbol", argv[1]))
+ {
+ nb = ADOBE(ptr);
+ } else {
+ len = 0;
+ }
+ ptr += nb;
+ len = len - nb;
+ }
+ return 0;
+}