mirror of
https://github.com/fltk/fltk.git
synced 2026-05-24 00:06:20 +08:00
xutf8 files code conformance:
o C files containing C++ "//" comments -> C style "/* */" comments
o Converted unintended doxygen style comments to regular C comments
o FLTK brace/indent coding standard conformance
o Tested linux + sgi
o Avoided mods to xutf8/lcUniConv [libiconv/FSF code]
to avoid unwanted diffs with future updates of that lib
as per Fabien's fltk.dev request 03/14/09.
(Those files already compliant anyway)
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6698 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
+77
-85
@@ -30,104 +30,96 @@
|
||||
#include "headers/case.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
int
|
||||
XUtf8Tolower(
|
||||
int ucs)
|
||||
{
|
||||
int ret;
|
||||
XUtf8Tolower(int ucs) {
|
||||
int ret;
|
||||
if (ucs <= 0x02B6) {
|
||||
if (ucs >= 0x0041) {
|
||||
ret = ucs_table_0041[ucs - 0x0041];
|
||||
if (ret > 0) return ret;
|
||||
}
|
||||
return ucs;
|
||||
}
|
||||
|
||||
if (ucs <= 0x02B6) {
|
||||
if (ucs >= 0x0041) {
|
||||
ret = ucs_table_0041[ucs - 0x0041];
|
||||
if (ret > 0) return ret;
|
||||
}
|
||||
return ucs;
|
||||
}
|
||||
if (ucs <= 0x0556) {
|
||||
if (ucs >= 0x0386) {
|
||||
ret = ucs_table_0386[ucs - 0x0386];
|
||||
if (ret > 0) return ret;
|
||||
}
|
||||
return ucs;
|
||||
}
|
||||
|
||||
if (ucs <= 0x0556) {
|
||||
if (ucs >= 0x0386) {
|
||||
ret = ucs_table_0386[ucs - 0x0386];
|
||||
if (ret > 0) return ret;
|
||||
}
|
||||
return ucs;
|
||||
}
|
||||
if (ucs <= 0x10C5) {
|
||||
if (ucs >= 0x10A0) {
|
||||
ret = ucs_table_10A0[ucs - 0x10A0];
|
||||
if (ret > 0) return ret;
|
||||
}
|
||||
return ucs;
|
||||
}
|
||||
|
||||
if (ucs <= 0x10C5) {
|
||||
if (ucs >= 0x10A0) {
|
||||
ret = ucs_table_10A0[ucs - 0x10A0];
|
||||
if (ret > 0) return ret;
|
||||
}
|
||||
return ucs;
|
||||
}
|
||||
if (ucs <= 0x1FFC) {
|
||||
if (ucs >= 0x1E00) {
|
||||
ret = ucs_table_1E00[ucs - 0x1E00];
|
||||
if (ret > 0) return ret;
|
||||
}
|
||||
return ucs;
|
||||
}
|
||||
|
||||
if (ucs <= 0x1FFC) {
|
||||
if (ucs >= 0x1E00) {
|
||||
ret = ucs_table_1E00[ucs - 0x1E00];
|
||||
if (ret > 0) return ret;
|
||||
}
|
||||
return ucs;
|
||||
}
|
||||
if (ucs <= 0x2133) {
|
||||
if (ucs >= 0x2102) {
|
||||
ret = ucs_table_2102[ucs - 0x2102];
|
||||
if (ret > 0) return ret;
|
||||
}
|
||||
return ucs;
|
||||
}
|
||||
|
||||
if (ucs <= 0x2133) {
|
||||
if (ucs >= 0x2102) {
|
||||
ret = ucs_table_2102[ucs - 0x2102];
|
||||
if (ret > 0) return ret;
|
||||
}
|
||||
return ucs;
|
||||
}
|
||||
if (ucs <= 0x24CF) {
|
||||
if (ucs >= 0x24B6) {
|
||||
ret = ucs_table_24B6[ucs - 0x24B6];
|
||||
if (ret > 0) return ret;
|
||||
}
|
||||
return ucs;
|
||||
}
|
||||
|
||||
if (ucs <= 0x24CF) {
|
||||
if (ucs >= 0x24B6) {
|
||||
ret = ucs_table_24B6[ucs - 0x24B6];
|
||||
if (ret > 0) return ret;
|
||||
}
|
||||
return ucs;
|
||||
}
|
||||
if (ucs <= 0x33CE) {
|
||||
if (ucs >= 0x33CE) {
|
||||
ret = ucs_table_33CE[ucs - 0x33CE];
|
||||
if (ret > 0) return ret;
|
||||
}
|
||||
return ucs;
|
||||
}
|
||||
|
||||
if (ucs <= 0x33CE) {
|
||||
if (ucs >= 0x33CE) {
|
||||
ret = ucs_table_33CE[ucs - 0x33CE];
|
||||
if (ret > 0) return ret;
|
||||
}
|
||||
return ucs;
|
||||
}
|
||||
if (ucs <= 0xFF3A) {
|
||||
if (ucs >= 0xFF21) {
|
||||
ret = ucs_table_FF21[ucs - 0xFF21];
|
||||
if (ret > 0) return ret;
|
||||
}
|
||||
return ucs;
|
||||
}
|
||||
|
||||
if (ucs <= 0xFF3A) {
|
||||
if (ucs >= 0xFF21) {
|
||||
ret = ucs_table_FF21[ucs - 0xFF21];
|
||||
if (ret > 0) return ret;
|
||||
}
|
||||
return ucs;
|
||||
}
|
||||
|
||||
return ucs;
|
||||
return ucs;
|
||||
}
|
||||
|
||||
int
|
||||
XUtf8Toupper(
|
||||
int ucs)
|
||||
{
|
||||
int i;
|
||||
static unsigned short *table = NULL;
|
||||
XUtf8Toupper(int ucs) {
|
||||
int i;
|
||||
static unsigned short *table = NULL;
|
||||
|
||||
if (!table) {
|
||||
table = (unsigned short*) malloc(
|
||||
sizeof(unsigned short) * 0x10000);
|
||||
for (i = 0; i < 0x10000; i++) {
|
||||
table[i] = (unsigned short) i;
|
||||
}
|
||||
for (i = 0; i < 0x10000; i++) {
|
||||
int l;
|
||||
l = XUtf8Tolower(i);
|
||||
if (l != i) table[l] = (unsigned short) i;
|
||||
}
|
||||
|
||||
}
|
||||
if (ucs >= 0x10000 || ucs < 0) return ucs;
|
||||
return table[ucs];
|
||||
if (!table) {
|
||||
table = (unsigned short*) malloc(sizeof(unsigned short) * 0x10000);
|
||||
for (i = 0; i < 0x10000; i++) {
|
||||
table[i] = (unsigned short) i;
|
||||
}
|
||||
for (i = 0; i < 0x10000; i++) {
|
||||
int l;
|
||||
l = XUtf8Tolower(i);
|
||||
if (l != i) table[l] = (unsigned short) i;
|
||||
}
|
||||
}
|
||||
if (ucs >= 0x10000 || ucs < 0) return ucs;
|
||||
return table[ucs];
|
||||
}
|
||||
|
||||
/*
|
||||
* End of "$Id$".
|
||||
*/
|
||||
* End of "$Id$".
|
||||
*/
|
||||
|
||||
+38
-40
@@ -28,57 +28,55 @@
|
||||
*/
|
||||
|
||||
unsigned short
|
||||
XUtf8IsRightToLeft(
|
||||
unsigned int ucs)
|
||||
{
|
||||
XUtf8IsRightToLeft(unsigned int ucs) {
|
||||
|
||||
#if 0
|
||||
/* for debug only */
|
||||
if (ucs <= 0x005A) {
|
||||
if (ucs >= 0x0041) return 1;
|
||||
return 0;
|
||||
}
|
||||
/* for debug only */
|
||||
if (ucs <= 0x005A) {
|
||||
if (ucs >= 0x0041) return 1;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* HEBREW */
|
||||
if (ucs <= 0x05F4) {
|
||||
if (ucs >= 0x0591) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ARABIC */
|
||||
if (ucs <= 0x06ED) {
|
||||
if (ucs >= 0x060C) return 1;
|
||||
return 0;
|
||||
}
|
||||
/* HEBREW */
|
||||
if (ucs <= 0x05F4) {
|
||||
if (ucs >= 0x0591) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ARABIC */
|
||||
if (ucs <= 0x06ED) {
|
||||
if (ucs >= 0x060C) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ucs <= 0x06F9) {
|
||||
if (ucs >= 0x06F0) return 1;
|
||||
return 0;
|
||||
}
|
||||
if (ucs <= 0x06F9) {
|
||||
if (ucs >= 0x06F0) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ucs == 0x200F) return 1;
|
||||
if (ucs == 0x200F) return 1;
|
||||
|
||||
if (ucs == 0x202B) return 1;
|
||||
if (ucs == 0x202B) return 1;
|
||||
|
||||
if (ucs == 0x202E) return 1;
|
||||
if (ucs == 0x202E) return 1;
|
||||
|
||||
if (ucs <= 0xFB4F) {
|
||||
if (ucs >= 0xFB1E) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ucs <= 0xFDFB) {
|
||||
if (ucs >= 0xFB50) return 1;
|
||||
return 0;
|
||||
}
|
||||
if (ucs <= 0xFB4F) {
|
||||
if (ucs >= 0xFB1E) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ucs <= 0xFDFB) {
|
||||
if (ucs >= 0xFB50) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ucs <= 0xFEFC) {
|
||||
if (ucs >= 0xFE70) return 1;
|
||||
return 0;
|
||||
}
|
||||
if (ucs <= 0xFEFC) {
|
||||
if (ucs >= 0xFE70) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
+42
-45
@@ -29,63 +29,60 @@
|
||||
|
||||
#include "headers/spacing.h"
|
||||
|
||||
|
||||
unsigned short
|
||||
XUtf8IsNonSpacing(
|
||||
unsigned int ucs)
|
||||
{
|
||||
XUtf8IsNonSpacing(unsigned int ucs) {
|
||||
|
||||
if (ucs <= 0x0361) {
|
||||
if (ucs >= 0x0300) return ucs_table_0300[ucs - 0x0300];
|
||||
return 0;
|
||||
}
|
||||
if (ucs <= 0x0361) {
|
||||
if (ucs >= 0x0300) return ucs_table_0300[ucs - 0x0300];
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ucs <= 0x0486) {
|
||||
if (ucs >= 0x0483) return ucs_table_0483[ucs - 0x0483];
|
||||
return 0;
|
||||
}
|
||||
if (ucs <= 0x0486) {
|
||||
if (ucs >= 0x0483) return ucs_table_0483[ucs - 0x0483];
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ucs <= 0x05C4) {
|
||||
if (ucs >= 0x0591) return ucs_table_0591[ucs - 0x0591];
|
||||
return 0;
|
||||
}
|
||||
if (ucs <= 0x05C4) {
|
||||
if (ucs >= 0x0591) return ucs_table_0591[ucs - 0x0591];
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ucs <= 0x06ED) {
|
||||
if (ucs >= 0x064B) return ucs_table_064B[ucs - 0x064B];
|
||||
return 0;
|
||||
}
|
||||
if (ucs <= 0x06ED) {
|
||||
if (ucs >= 0x064B) return ucs_table_064B[ucs - 0x064B];
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ucs <= 0x0D4D) {
|
||||
if (ucs >= 0x0901) return ucs_table_0901[ucs - 0x0901];
|
||||
return 0;
|
||||
}
|
||||
if (ucs <= 0x0D4D) {
|
||||
if (ucs >= 0x0901) return ucs_table_0901[ucs - 0x0901];
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ucs <= 0x0FB9) {
|
||||
if (ucs >= 0x0E31) return ucs_table_0E31[ucs - 0x0E31];
|
||||
return 0;
|
||||
}
|
||||
if (ucs <= 0x0FB9) {
|
||||
if (ucs >= 0x0E31) return ucs_table_0E31[ucs - 0x0E31];
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ucs <= 0x20E1) {
|
||||
if (ucs >= 0x20D0) return ucs_table_20D0[ucs - 0x20D0];
|
||||
return 0;
|
||||
}
|
||||
if (ucs <= 0x20E1) {
|
||||
if (ucs >= 0x20D0) return ucs_table_20D0[ucs - 0x20D0];
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ucs <= 0x309A) {
|
||||
if (ucs >= 0x302A) return ucs_table_302A[ucs - 0x302A];
|
||||
return 0;
|
||||
}
|
||||
if (ucs <= 0x309A) {
|
||||
if (ucs >= 0x302A) return ucs_table_302A[ucs - 0x302A];
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ucs <= 0xFB1E) {
|
||||
if (ucs >= 0xFB1E) return ucs_table_FB1E[ucs - 0xFB1E];
|
||||
return 0;
|
||||
}
|
||||
if (ucs <= 0xFB1E) {
|
||||
if (ucs >= 0xFB1E) return ucs_table_FB1E[ucs - 0xFB1E];
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ucs <= 0xFE23) {
|
||||
if (ucs >= 0xFE20) return ucs_table_FE20[ucs - 0xFE20];
|
||||
return 0;
|
||||
}
|
||||
if (ucs <= 0xFE23) {
|
||||
if (ucs >= 0xFE20) return ucs_table_FE20[ucs - 0xFE20];
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -30,10 +30,8 @@
|
||||
#include "../../FL/Xutf8.h"
|
||||
#include "imKStoUCS.c"
|
||||
|
||||
|
||||
long XKeysymToUcs(KeySym keysym)
|
||||
{
|
||||
return (long) KeySymToUcs4(keysym);
|
||||
long XKeysymToUcs(KeySym keysym) {
|
||||
return (long) KeySymToUcs4(keysym);
|
||||
}
|
||||
|
||||
#endif /* X11 only */
|
||||
|
||||
+197
-194
@@ -26,7 +26,9 @@
|
||||
/*
|
||||
* UTF-8 X test program (It contains MINIMAL code to support XIM !!!)
|
||||
*
|
||||
To test it do :
|
||||
****************
|
||||
* To test it do:
|
||||
****************
|
||||
|
||||
kinput2 -canna
|
||||
XMODIFIERS="@im=kinput2"; export XMODIFIERS
|
||||
@@ -51,7 +53,7 @@ export LANG=ko_KR; export XMODIFIERS="@im=Ami"
|
||||
export LANG=zh_TW; export XMODIFIERS="@im=xcin-zh_TW"
|
||||
export LANG=zh_TW; export XMODIFIERS="@im=xcin-zh_CN"
|
||||
export LANG=C; export XMODIFIERS="@im=interxim"
|
||||
*/
|
||||
**********************************************************/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -80,208 +82,209 @@ GC gc;
|
||||
int x = 2;
|
||||
int y = 40;
|
||||
|
||||
int main(int argc, char**argv)
|
||||
{
|
||||
char **missing_charset_list;
|
||||
int missing_charset_count;
|
||||
XGCValues xgcv;
|
||||
unsigned long mask;
|
||||
Display* dpy;
|
||||
int scr;
|
||||
Window w, root;
|
||||
XSetWindowAttributes set_attr;
|
||||
int i;
|
||||
XIMStyle *style;
|
||||
static char buf[128];
|
||||
KeySym keysym = 0;
|
||||
Status status;
|
||||
XWMHints wm_hints;
|
||||
XClassHint class_hints;
|
||||
XIMStyle input_style = 0;
|
||||
char **font_name_list;
|
||||
char *def_string;
|
||||
XFontStruct **font_struct_list;
|
||||
char **font_encoding_list;
|
||||
int nb_font;
|
||||
int len = 0;
|
||||
int no_xim = 0;
|
||||
int main(int argc, char**argv) {
|
||||
char **missing_charset_list;
|
||||
int missing_charset_count;
|
||||
XGCValues xgcv;
|
||||
unsigned long mask;
|
||||
Display* dpy;
|
||||
int scr;
|
||||
Window w, root;
|
||||
XSetWindowAttributes set_attr;
|
||||
int i;
|
||||
XIMStyle *style;
|
||||
static char buf[128];
|
||||
KeySym keysym = 0;
|
||||
Status status;
|
||||
XWMHints wm_hints;
|
||||
XClassHint class_hints;
|
||||
XIMStyle input_style = 0;
|
||||
char **font_name_list;
|
||||
char *def_string;
|
||||
XFontStruct **font_struct_list;
|
||||
char **font_encoding_list;
|
||||
int nb_font;
|
||||
int len = 0;
|
||||
int no_xim = 0;
|
||||
|
||||
printf ("A -> %c \n", XUtf8Tolower('A'));
|
||||
if (!setlocale(LC_ALL, ""))
|
||||
puts("locale not supported by C library, locale unchanged");
|
||||
printf ("A -> %c \n", XUtf8Tolower('A'));
|
||||
if (!setlocale(LC_ALL, ""))
|
||||
puts("locale not supported by C library, locale unchanged");
|
||||
|
||||
if (!XSetLocaleModifiers(""))
|
||||
puts("X locale modifiers not supported, using default");
|
||||
|
||||
dpy = XOpenDisplay(0);
|
||||
if (!dpy) { puts("cannot open display.\n"); exit(-1); }
|
||||
scr = DefaultScreen(dpy);
|
||||
root = RootWindow(dpy, scr);
|
||||
set_attr.event_mask = KeyPressMask|FocusChangeMask;
|
||||
set_attr.background_pixel = WhitePixel(dpy, DefaultScreen(dpy));
|
||||
set_attr.border_pixel = BlackPixel(dpy, DefaultScreen(dpy));
|
||||
w = XCreateWindow(dpy, root, 10,10,200,100,0,
|
||||
DefaultDepth(dpy, DefaultScreen(dpy)),
|
||||
InputOutput, DefaultVisual(dpy, DefaultScreen(dpy)),
|
||||
CWEventMask | CWBackPixel | CWBorderPixel, &set_attr);
|
||||
if (!w) { puts("cannot creat window.\n"); exit(-1); }
|
||||
if (!XSetLocaleModifiers(""))
|
||||
puts("X locale modifiers not supported, using default");
|
||||
|
||||
dpy = XOpenDisplay(0);
|
||||
if (!dpy) { puts("cannot open display.\n"); exit(-1); }
|
||||
scr = DefaultScreen(dpy);
|
||||
root = RootWindow(dpy, scr);
|
||||
set_attr.event_mask = KeyPressMask|FocusChangeMask;
|
||||
set_attr.background_pixel = WhitePixel(dpy, DefaultScreen(dpy));
|
||||
set_attr.border_pixel = BlackPixel(dpy, DefaultScreen(dpy));
|
||||
w = XCreateWindow(dpy, root, 10,10,200,100,0,
|
||||
DefaultDepth(dpy, DefaultScreen(dpy)),
|
||||
InputOutput, DefaultVisual(dpy, DefaultScreen(dpy)),
|
||||
CWEventMask | CWBackPixel | CWBorderPixel, &set_attr);
|
||||
if (!w) {
|
||||
puts("cannot creat window.\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
class_hints.res_name = "test";
|
||||
class_hints.res_class = "Test";
|
||||
wm_hints.input = True;
|
||||
wm_hints.flags = InputHint;
|
||||
class_hints.res_name = "test";
|
||||
class_hints.res_class = "Test";
|
||||
wm_hints.input = True;
|
||||
wm_hints.flags = InputHint;
|
||||
|
||||
XmbSetWMProperties(dpy, w, "test", "test", NULL, 0,
|
||||
NULL, &wm_hints, &class_hints);
|
||||
XmbSetWMProperties(dpy, w, "test", "test", NULL, 0,
|
||||
NULL, &wm_hints, &class_hints);
|
||||
|
||||
XMapWindow(dpy, w);
|
||||
xim_im = XOpenIM(dpy, NULL, "test", "Test");
|
||||
if (!xim_im) {
|
||||
puts("cannot Open Input Manager: Try default.\n");
|
||||
XSetLocaleModifiers("@im=");
|
||||
xim_im = XOpenIM(dpy, NULL, "test", "Test");
|
||||
if (!xim_im) { puts("Failed exiting.\n"); exit(-1); }
|
||||
}
|
||||
XGetIMValues (xim_im, XNQueryInputStyle, &xim_styles, NULL, NULL);
|
||||
for (i = 0, style = xim_styles->supported_styles;
|
||||
i < xim_styles->count_styles; i++, style++)
|
||||
{
|
||||
if (i == 0 && *style == (XIMStatusNone|XIMPreeditNone)) {
|
||||
printf("this is not a XIM server !!!\n");
|
||||
no_xim = 1;
|
||||
}
|
||||
printf("input style : 0x%X\n", *style);
|
||||
}
|
||||
XMapWindow(dpy, w);
|
||||
xim_im = XOpenIM(dpy, NULL, "test", "Test");
|
||||
if (!xim_im) {
|
||||
puts("cannot Open Input Manager: Try default.\n");
|
||||
XSetLocaleModifiers("@im=");
|
||||
xim_im = XOpenIM(dpy, NULL, "test", "Test");
|
||||
if (!xim_im) {
|
||||
puts("Failed exiting.\n");
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
XGetIMValues (xim_im, XNQueryInputStyle, &xim_styles, NULL, NULL);
|
||||
for (i = 0, style = xim_styles->supported_styles;
|
||||
i < xim_styles->count_styles; i++, style++) {
|
||||
if (i == 0 && *style == (XIMStatusNone|XIMPreeditNone)) {
|
||||
printf("this is not a XIM server !!!\n");
|
||||
no_xim = 1;
|
||||
}
|
||||
printf("input style : 0x%X\n", *style);
|
||||
}
|
||||
|
||||
xim_ic = XCreateIC(xim_im,
|
||||
XNInputStyle,
|
||||
(XIMPreeditNothing | XIMStatusNothing),
|
||||
XNClientWindow, w,
|
||||
XNFocusWindow, w,
|
||||
NULL);
|
||||
if (!xim_ic) {
|
||||
puts("cannot create Input Context.\n");
|
||||
exit(-1);
|
||||
}
|
||||
XFree(xim_styles);
|
||||
XSetICFocus(xim_ic);
|
||||
|
||||
/***************************************************************
|
||||
* I don't recommend to use a font base name list similar
|
||||
* to the following one in a real application ;-)
|
||||
* You should use an iso8859-1 font, plus a single font for
|
||||
* your language.
|
||||
***************************************************************/
|
||||
fontset = XCreateUtf8FontStruct(dpy,
|
||||
"-*-*-*-*-*-*-*-*-*-*-*-*-iso8858-3," /* not valid */
|
||||
"-*-*-medium-r-*-*-*-*-*-*-*-*-iso8859-1,"
|
||||
"-*-*-*-*-*-*-*-*-*-*-*-*-iso8859-6,"
|
||||
"-*-*-*-*-*-*-*-*-*-*-*-*-iso8859-8,"
|
||||
"-*-*-*-*-*-*-*-*-*-*-*-*-ksc5601.1987-0,"
|
||||
"-*-symbol-*-*-*-*-*-*-*-*-*-*-adobe-fontspecific,"
|
||||
"-*-*-*-*-*-*-*-*-*-*-*-*-iso8859-2,"
|
||||
"-*-*-*-*-*-*-*-*-*-*-*-*-koi8-1,"
|
||||
"-*-*-*-*-*-*-*-*-*-*-*-*-jisx0208.1983-0,"
|
||||
"-*-*-*-*-*-*-*-*-*-*-*-*-jisx0212.1990-0,"
|
||||
"-*-*-*-*-*-*-*-*-*-*-*-*-big5-0,"
|
||||
"-*-*-*-*-*-*-*-*-*-*-*-*-jisx0201.1976-0,"
|
||||
"-*-unifont-*-*-*-*-*-*-*-*-*-*-iso10646-1[0x300 0x400_0x500],"
|
||||
"-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
|
||||
|
||||
/* THIS PART IS NOT REQUIERED */
|
||||
nb_font = fontset->nb_font;
|
||||
|
||||
while (nb_font > 0) {
|
||||
nb_font--;
|
||||
if (fontset->fonts[nb_font]) {
|
||||
printf("encoding=\"\" fid=%d \n %s\n",
|
||||
// fontset->encodings[nb_font],
|
||||
fontset->fonts[nb_font]->fid,
|
||||
fontset->font_name_list[nb_font]);
|
||||
}
|
||||
}
|
||||
/* END OF NOT REQUIERED PART*/
|
||||
|
||||
mask = (GCForeground | GCBackground);
|
||||
xgcv.foreground = BlackPixel(dpy, DefaultScreen(dpy));
|
||||
xgcv.background = WhitePixel(dpy, DefaultScreen(dpy));
|
||||
|
||||
gc = XCreateGC(dpy, w, mask, &xgcv);
|
||||
if (!gc) {
|
||||
puts("cannot create Graphic Context.\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
/***************************************************************/
|
||||
while (1) {
|
||||
int filtered;
|
||||
static XEvent xevent;
|
||||
static XVaNestedList list1 = 0;
|
||||
int r;
|
||||
|
||||
XNextEvent(dpy, &xevent);
|
||||
if (xevent.type == KeyPress) {
|
||||
XKeyEvent *e = (XKeyEvent*) &xevent;
|
||||
printf ("0x%X %d\n", e->state, e->keycode);
|
||||
}
|
||||
if (xevent.type == DestroyNotify) {
|
||||
/* XIM server has crashed */
|
||||
no_xim = 1;
|
||||
XSetLocaleModifiers("@im=");
|
||||
xim_im = XOpenIM(dpy, NULL, "test", "Test");
|
||||
if (xim_im) {
|
||||
xim_ic = XCreateIC(xim_im,
|
||||
XNInputStyle,
|
||||
(XIMPreeditNothing | XIMStatusNothing),
|
||||
XNClientWindow, w,
|
||||
XNFocusWindow, w,
|
||||
NULL);
|
||||
if (!xim_ic) { puts("cannot create Input Context.\n"); exit(-1);}
|
||||
XFree(xim_styles);
|
||||
XSetICFocus(xim_ic);
|
||||
XNInputStyle, (XIMPreeditNothing | XIMStatusNothing),
|
||||
XNClientWindow, w,
|
||||
XNFocusWindow, w,
|
||||
NULL);
|
||||
} else {
|
||||
xim_ic = NULL;
|
||||
}
|
||||
if (!xim_ic) {
|
||||
puts("Crash recovery failed. exiting.\n");
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
if (xevent.type != DestroyNotify) {
|
||||
filtered = XFilterEvent(&xevent, 0);
|
||||
}
|
||||
if (xevent.type == FocusOut && xim_ic) XUnsetICFocus(xim_ic);
|
||||
if (xevent.type == FocusIn && xim_ic) XSetICFocus(xim_ic);
|
||||
|
||||
/***************************************************************/
|
||||
/** I don't recommand to use a font base name list similar
|
||||
* to the following one in a real application ;-)
|
||||
* You should use an iso8859-1 font, plus a single font for
|
||||
* your language. */
|
||||
/***************************************************************/
|
||||
fontset = XCreateUtf8FontStruct(dpy,
|
||||
"-*-*-*-*-*-*-*-*-*-*-*-*-iso8858-3," /* not valid */
|
||||
"-*-*-medium-r-*-*-*-*-*-*-*-*-iso8859-1,"
|
||||
"-*-*-*-*-*-*-*-*-*-*-*-*-iso8859-6,"
|
||||
"-*-*-*-*-*-*-*-*-*-*-*-*-iso8859-8,"
|
||||
"-*-*-*-*-*-*-*-*-*-*-*-*-ksc5601.1987-0,"
|
||||
"-*-symbol-*-*-*-*-*-*-*-*-*-*-adobe-fontspecific,"
|
||||
"-*-*-*-*-*-*-*-*-*-*-*-*-iso8859-2,"
|
||||
"-*-*-*-*-*-*-*-*-*-*-*-*-koi8-1,"
|
||||
"-*-*-*-*-*-*-*-*-*-*-*-*-jisx0208.1983-0,"
|
||||
"-*-*-*-*-*-*-*-*-*-*-*-*-jisx0212.1990-0,"
|
||||
"-*-*-*-*-*-*-*-*-*-*-*-*-big5-0,"
|
||||
"-*-*-*-*-*-*-*-*-*-*-*-*-jisx0201.1976-0,"
|
||||
"-*-unifont-*-*-*-*-*-*-*-*-*-*-iso10646-1[0x300 0x400_0x500],"
|
||||
"-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
|
||||
if (xevent.type == KeyPress && !filtered) {
|
||||
len = XUtf8LookupString(xim_ic, &xevent.xkey,
|
||||
buf, 127, &keysym, &status);
|
||||
|
||||
/* THIS PART IS NOT REQUIERED */
|
||||
nb_font = fontset->nb_font;
|
||||
if (len == 1 && buf[0] == '\b') {
|
||||
x -= XUtf8TextWidth(fontset, buf, len);
|
||||
XUtf8DrawImageString(dpy, w, fontset, gc,
|
||||
x, y, buf, len);
|
||||
} else if (len == 1 && buf[0] == '\r') {
|
||||
y += fontset->ascent + fontset->descent;
|
||||
x = 0;
|
||||
XCloseIM(xim_im);
|
||||
} else {
|
||||
XUtf8DrawImageString(dpy, w, fontset, gc, x, y, buf, len);
|
||||
x += XUtf8TextWidth(fontset, buf, len);
|
||||
}
|
||||
|
||||
while (nb_font > 0) {
|
||||
nb_font--;
|
||||
if (fontset->fonts[nb_font]) {
|
||||
printf("encoding=\"\" fid=%d \n %s\n",
|
||||
// fontset->encodings[nb_font],
|
||||
fontset->fonts[nb_font]->fid,
|
||||
fontset->font_name_list[nb_font]);
|
||||
}
|
||||
}
|
||||
/* END OF NOT REQUIERED PART*/
|
||||
|
||||
mask = (GCForeground | GCBackground);
|
||||
xgcv.foreground = BlackPixel(dpy, DefaultScreen(dpy));
|
||||
xgcv.background = WhitePixel(dpy, DefaultScreen(dpy));
|
||||
|
||||
gc = XCreateGC(dpy, w, mask, &xgcv);
|
||||
if (!gc) { puts("cannot create Graphic Context.\n"); exit(-1);}
|
||||
|
||||
|
||||
/***************************************************************/
|
||||
while (1) {
|
||||
int filtered;
|
||||
static XEvent xevent;
|
||||
static XVaNestedList list1 = 0;
|
||||
int r;
|
||||
|
||||
XNextEvent(dpy, &xevent);
|
||||
if (xevent.type == KeyPress) {
|
||||
XKeyEvent *e = (XKeyEvent*) &xevent;
|
||||
printf ("0x%X %d\n", e->state, e->keycode);
|
||||
}
|
||||
if (xevent.type == DestroyNotify) {
|
||||
/* XIM server has crashed */
|
||||
no_xim = 1;
|
||||
XSetLocaleModifiers("@im=");
|
||||
xim_im = XOpenIM(dpy, NULL, "test", "Test");
|
||||
if (xim_im) {
|
||||
xim_ic = XCreateIC(xim_im,
|
||||
XNInputStyle, (XIMPreeditNothing |
|
||||
XIMStatusNothing),
|
||||
XNClientWindow, w,
|
||||
XNFocusWindow, w,
|
||||
NULL);
|
||||
} else {
|
||||
xim_ic = NULL;
|
||||
}
|
||||
if (!xim_ic) {
|
||||
puts("Crash recovery failed. exiting.\n");
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
if (xevent.type != DestroyNotify) {
|
||||
filtered = XFilterEvent(&xevent, 0);
|
||||
}
|
||||
if (xevent.type == FocusOut && xim_ic) XUnsetICFocus(xim_ic);
|
||||
if (xevent.type == FocusIn && xim_ic) XSetICFocus(xim_ic);
|
||||
|
||||
if (xevent.type == KeyPress && !filtered) {
|
||||
len = XUtf8LookupString(xim_ic, &xevent.xkey,
|
||||
buf, 127, &keysym, &status);
|
||||
|
||||
if (len == 1 && buf[0] == '\b') {
|
||||
x -= XUtf8TextWidth(fontset, buf, len);
|
||||
XUtf8DrawImageString(dpy, w, fontset, gc,
|
||||
x, y, buf, len);
|
||||
} else if (len == 1 && buf[0] == '\r') {
|
||||
y += fontset->ascent + fontset->descent;
|
||||
x = 0;
|
||||
XCloseIM(xim_im);
|
||||
} else {
|
||||
XUtf8DrawImageString(dpy, w, fontset, gc,
|
||||
x, y, buf, len);
|
||||
x += XUtf8TextWidth(fontset, buf, len);
|
||||
}
|
||||
|
||||
|
||||
XUtf8DrawString(dpy, w, fontset, gc, 0, 20,
|
||||
jp_txt, strlen(jp_txt));
|
||||
|
||||
XUtf8DrawString(dpy, w, fontset, gc, 50, 90,
|
||||
rtl_txt, strlen(rtl_txt));
|
||||
XUtf8DrawRtlString(dpy, w, fontset, gc,
|
||||
50, 90, rtl_txt, strlen(rtl_txt));
|
||||
buf[len] = 0;
|
||||
printf("'%s' %d %x\n", buf, keysym, keysym);
|
||||
buf[0] = 0;
|
||||
|
||||
}
|
||||
if (filtered) {
|
||||
printf("Dead key\n");
|
||||
}
|
||||
}
|
||||
XFreeUtf8FontStruct(dpy, fontset);
|
||||
return 0;
|
||||
XUtf8DrawString(dpy, w, fontset, gc, 0, 20, jp_txt, strlen(jp_txt));
|
||||
XUtf8DrawString(dpy, w, fontset, gc, 50, 90, rtl_txt, strlen(rtl_txt));
|
||||
XUtf8DrawRtlString(dpy, w, fontset, gc, 50, 90, rtl_txt, strlen(rtl_txt));
|
||||
buf[len] = 0;
|
||||
printf("'%s' %d %x\n", buf, keysym, keysym);
|
||||
buf[0] = 0;
|
||||
}
|
||||
if (filtered) {
|
||||
printf("Dead key\n");
|
||||
}
|
||||
}
|
||||
XFreeUtf8FontStruct(dpy, fontset);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
+128
-137
@@ -26,7 +26,9 @@
|
||||
/*
|
||||
* UTF-8 X test program
|
||||
*
|
||||
To test it do :
|
||||
*****************
|
||||
* To test it do :
|
||||
*****************
|
||||
|
||||
kinput2 -canna
|
||||
XMODIFIERS="@im=kinput2"; export XMODIFIERS
|
||||
@@ -68,9 +70,9 @@ export LD_PRELOAD="/usr/src/x11/xc/exports/lib/libX11.so /usr/src/x11/xc/exports
|
||||
#include <X11/Xmd.h>
|
||||
|
||||
char *jp_txt = "é UTF-8 e\xCC\x82=\xC3\xAA"
|
||||
" \357\274\270\357\274\254\357\274\246\357\274"
|
||||
"\244\345\220\215\343\201\247\346\214\207 \345\256\232"
|
||||
"\343\201\231\343\202\213";
|
||||
" \357\274\270\357\274\254\357\274\246\357\274"
|
||||
"\244\345\220\215\343\201\247\346\214\207 \345\256\232"
|
||||
"\343\201\231\343\202\213";
|
||||
|
||||
char *rtl_txt = "->e\xCC\x82=\xC3\xAA";
|
||||
|
||||
@@ -82,149 +84,138 @@ GC gc;
|
||||
int x = 2;
|
||||
int y = 40;
|
||||
|
||||
int main(int argc, char**argv)
|
||||
{
|
||||
char **missing_charset_list;
|
||||
int missing_charset_count;
|
||||
XGCValues xgcv;
|
||||
unsigned long mask;
|
||||
Display* dpy;
|
||||
int scr;
|
||||
Window w, root;
|
||||
XSetWindowAttributes set_attr;
|
||||
int i;
|
||||
XIMStyle *style;
|
||||
static char buf[128];
|
||||
KeySym keysym = 0;
|
||||
Status status;
|
||||
XWMHints wm_hints;
|
||||
XClassHint class_hints;
|
||||
XIMStyle input_style = 0;
|
||||
char **font_name_list;
|
||||
char *def_string;
|
||||
XFontStruct **font_struct_list;
|
||||
char **font_encoding_list;
|
||||
int nb_font;
|
||||
int len = 0;
|
||||
int no_xim = 0;
|
||||
char **missing_charset_list_return;
|
||||
int missing_charset_count_return;
|
||||
char *def_string_return;
|
||||
|
||||
if (!setlocale(LC_ALL, ""))
|
||||
puts("locale not supported by C library, locale unchanged");
|
||||
int main(int argc, char**argv) {
|
||||
char **missing_charset_list;
|
||||
int missing_charset_count;
|
||||
XGCValues xgcv;
|
||||
unsigned long mask;
|
||||
Display* dpy;
|
||||
int scr;
|
||||
Window w, root;
|
||||
XSetWindowAttributes set_attr;
|
||||
int i;
|
||||
XIMStyle *style;
|
||||
static char buf[128];
|
||||
KeySym keysym = 0;
|
||||
Status status;
|
||||
XWMHints wm_hints;
|
||||
XClassHint class_hints;
|
||||
XIMStyle input_style = 0;
|
||||
char **font_name_list;
|
||||
char *def_string;
|
||||
XFontStruct **font_struct_list;
|
||||
char **font_encoding_list;
|
||||
int nb_font;
|
||||
int len = 0;
|
||||
int no_xim = 0;
|
||||
char **missing_charset_list_return;
|
||||
int missing_charset_count_return;
|
||||
char *def_string_return;
|
||||
|
||||
if (!setlocale(LC_ALL, ""))
|
||||
puts("locale not supported by C library, locale unchanged");
|
||||
|
||||
if (!XSetLocaleModifiers(""))
|
||||
puts("X locale modifiers not supported, using default");
|
||||
|
||||
dpy = XOpenDisplay(0);
|
||||
scr = DefaultScreen(dpy);
|
||||
root = RootWindow(dpy, scr);
|
||||
set_attr.event_mask = KeyPressMask|FocusChangeMask;
|
||||
set_attr.background_pixel = WhitePixel(dpy, DefaultScreen(dpy));
|
||||
set_attr.border_pixel = BlackPixel(dpy, DefaultScreen(dpy));
|
||||
w = XCreateWindow(dpy, root, 10,10,200,100,0,
|
||||
DefaultDepth(dpy, DefaultScreen(dpy)),
|
||||
InputOutput, DefaultVisual(dpy, DefaultScreen(dpy)),
|
||||
CWEventMask | CWBackPixel | CWBorderPixel, &set_attr);
|
||||
if (!XSetLocaleModifiers(""))
|
||||
puts("X locale modifiers not supported, using default");
|
||||
|
||||
dpy = XOpenDisplay(0);
|
||||
scr = DefaultScreen(dpy);
|
||||
root = RootWindow(dpy, scr);
|
||||
set_attr.event_mask = KeyPressMask|FocusChangeMask;
|
||||
set_attr.background_pixel = WhitePixel(dpy, DefaultScreen(dpy));
|
||||
set_attr.border_pixel = BlackPixel(dpy, DefaultScreen(dpy));
|
||||
w = XCreateWindow(dpy, root, 10,10,200,100,0,
|
||||
DefaultDepth(dpy, DefaultScreen(dpy)),
|
||||
InputOutput, DefaultVisual(dpy, DefaultScreen(dpy)),
|
||||
CWEventMask | CWBackPixel | CWBorderPixel, &set_attr);
|
||||
|
||||
class_hints.res_name = "test";
|
||||
class_hints.res_class = "Test";
|
||||
wm_hints.input = True;
|
||||
wm_hints.flags = InputHint;
|
||||
class_hints.res_name = "test";
|
||||
class_hints.res_class = "Test";
|
||||
wm_hints.input = True;
|
||||
wm_hints.flags = InputHint;
|
||||
|
||||
XmbSetWMProperties(dpy, w, "test", "test", NULL, 0,
|
||||
NULL, &wm_hints, &class_hints);
|
||||
XmbSetWMProperties(dpy, w, "test", "test", NULL, 0,
|
||||
NULL, &wm_hints, &class_hints);
|
||||
|
||||
XMapWindow(dpy, w);
|
||||
xim_im = XOpenIM(dpy, NULL, "test", "Test");
|
||||
XGetIMValues (xim_im, XNQueryInputStyle, &xim_styles, NULL, NULL);
|
||||
for (i = 0, style = xim_styles->supported_styles;
|
||||
i < xim_styles->count_styles; i++, style++)
|
||||
{
|
||||
if (*style == (XIMStatusNone|XIMPreeditNone)) {
|
||||
printf("this is not a XIM server !!!\n");
|
||||
no_xim = 1;
|
||||
}
|
||||
printf("input style : 0x%X\n", *style);
|
||||
}
|
||||
XFree(xim_styles);
|
||||
XMapWindow(dpy, w);
|
||||
xim_im = XOpenIM(dpy, NULL, "test", "Test");
|
||||
XGetIMValues(xim_im, XNQueryInputStyle, &xim_styles, NULL, NULL);
|
||||
for (i = 0, style = xim_styles->supported_styles;
|
||||
i < xim_styles->count_styles; i++, style++) {
|
||||
if (*style == (XIMStatusNone|XIMPreeditNone)) {
|
||||
printf("this is not a XIM server !!!\n");
|
||||
no_xim = 1;
|
||||
}
|
||||
printf("input style : 0x%X\n", *style);
|
||||
}
|
||||
XFree(xim_styles);
|
||||
|
||||
xim_ic = XCreateIC(xim_im,
|
||||
XNInputStyle, (XIMPreeditNothing | XIMStatusNothing),
|
||||
XNClientWindow, w,
|
||||
XNFocusWindow, w,
|
||||
NULL);
|
||||
XSetICFocus(xim_ic);
|
||||
xim_ic = XCreateIC(xim_im,
|
||||
XNInputStyle, (XIMPreeditNothing | XIMStatusNothing),
|
||||
XNClientWindow, w,
|
||||
XNFocusWindow, w,
|
||||
NULL);
|
||||
XSetICFocus(xim_ic);
|
||||
|
||||
/***************************************************************/
|
||||
/** I don't recommand to use a font base name list similar
|
||||
* to the following one in a real application ;-) */
|
||||
/***************************************************************/
|
||||
fontset = XCreateFontSet(dpy,
|
||||
"-*-*-*-*-*-*-*-*-*-*-*-*-iso8858-3," /* not valid */
|
||||
"-*-*-medium-r-*-*-*-*-*-*-*-*-iso8859-1,"
|
||||
"-*-*-*-*-*-*-*-*-*-*-*-*-iso8859-6,"
|
||||
"-*-*-*-*-*-*-*-*-*-*-*-*-iso8859-8,"
|
||||
"-*-symbol-*-*-*-*-*-*-*-*-*-*-adobe-fontspecific,"
|
||||
"-*-*-*-*-*-*-*-*-*-*-*-*-iso8859-2,"
|
||||
"-*-*-*-*-*-*-*-*-*-*-*-*-koi8-1,"
|
||||
"-*-*-*-*-*-*-*-*-*-*-*-*-jisx0208.1983-0,"
|
||||
"-*-*-*-*-*-*-*-*-*-*-*-*-jisx0212.1990-0,"
|
||||
"-*-*-*-*-*-*-*-*-*-*-*-*-big5-0,"
|
||||
"-*-*-*-*-*-*-*-*-*-*-*-*-jisx0201.1976-0,"
|
||||
"-*-unifont-*-*-*-*-*-*-*-*-*-*-iso10646-1[0x300 0x400_0x500],"
|
||||
"-*-*-*-*-*-*-*-*-*-*-*-*-*-*",
|
||||
&missing_charset_list_return,
|
||||
&missing_charset_count_return,
|
||||
&def_string_return);
|
||||
mask = (GCForeground | GCBackground);
|
||||
xgcv.foreground = BlackPixel(dpy, DefaultScreen(dpy));
|
||||
xgcv.background = WhitePixel(dpy, DefaultScreen(dpy));
|
||||
/***************************************************************
|
||||
* I don't recommend to use a font base name list similar
|
||||
* to the following one in a real application ;-)
|
||||
***************************************************************/
|
||||
fontset = XCreateFontSet(dpy,
|
||||
"-*-*-*-*-*-*-*-*-*-*-*-*-iso8858-3," /* not valid */
|
||||
"-*-*-medium-r-*-*-*-*-*-*-*-*-iso8859-1,"
|
||||
"-*-*-*-*-*-*-*-*-*-*-*-*-iso8859-6,"
|
||||
"-*-*-*-*-*-*-*-*-*-*-*-*-iso8859-8,"
|
||||
"-*-symbol-*-*-*-*-*-*-*-*-*-*-adobe-fontspecific,"
|
||||
"-*-*-*-*-*-*-*-*-*-*-*-*-iso8859-2,"
|
||||
"-*-*-*-*-*-*-*-*-*-*-*-*-koi8-1,"
|
||||
"-*-*-*-*-*-*-*-*-*-*-*-*-jisx0208.1983-0,"
|
||||
"-*-*-*-*-*-*-*-*-*-*-*-*-jisx0212.1990-0,"
|
||||
"-*-*-*-*-*-*-*-*-*-*-*-*-big5-0,"
|
||||
"-*-*-*-*-*-*-*-*-*-*-*-*-jisx0201.1976-0,"
|
||||
"-*-unifont-*-*-*-*-*-*-*-*-*-*-iso10646-1[0x300 0x400_0x500],"
|
||||
"-*-*-*-*-*-*-*-*-*-*-*-*-*-*",
|
||||
&missing_charset_list_return,
|
||||
&missing_charset_count_return,
|
||||
&def_string_return);
|
||||
mask = (GCForeground | GCBackground);
|
||||
xgcv.foreground = BlackPixel(dpy, DefaultScreen(dpy));
|
||||
xgcv.background = WhitePixel(dpy, DefaultScreen(dpy));
|
||||
|
||||
gc = XCreateGC(dpy, w, mask, &xgcv);
|
||||
gc = XCreateGC(dpy, w, mask, &xgcv);
|
||||
|
||||
/***************************************************************/
|
||||
while (1) {
|
||||
int filtered;
|
||||
static XEvent xevent;
|
||||
static XVaNestedList list1 = 0;
|
||||
int r;
|
||||
|
||||
/***************************************************************/
|
||||
while (1) {
|
||||
int filtered;
|
||||
static XEvent xevent;
|
||||
static XVaNestedList list1 = 0;
|
||||
int r;
|
||||
XNextEvent(dpy, &xevent);
|
||||
if (xevent.type == KeyPress) {
|
||||
XKeyEvent *e = (XKeyEvent*) &xevent;
|
||||
printf ("0x%X %d\n", e->state, e->keycode);
|
||||
}
|
||||
filtered = XFilterEvent(&xevent, w);
|
||||
if (xevent.type == FocusOut) XUnsetICFocus(xim_ic);
|
||||
if (xevent.type == FocusIn) XSetICFocus(xim_ic);
|
||||
|
||||
XNextEvent(dpy, &xevent);
|
||||
if (xevent.type == KeyPress) {
|
||||
XKeyEvent *e = (XKeyEvent*) &xevent;
|
||||
printf ("0x%X %d\n", e->state, e->keycode);
|
||||
}
|
||||
filtered = XFilterEvent(&xevent, w);
|
||||
if (xevent.type == FocusOut) XUnsetICFocus(xim_ic);
|
||||
if (xevent.type == FocusIn) XSetICFocus(xim_ic);
|
||||
|
||||
if (xevent.type == KeyPress && !filtered) {
|
||||
len = Xutf8LookupString(xim_ic, &xevent.xkey,
|
||||
buf, 127, &keysym, &status);
|
||||
|
||||
Xutf8DrawImageString(dpy, w, fontset, gc,
|
||||
x, y, buf, len);
|
||||
|
||||
|
||||
Xutf8DrawString(dpy, w, fontset, gc, 0, 20,
|
||||
jp_txt, strlen(jp_txt));
|
||||
|
||||
Xutf8DrawString(dpy, w, fontset, gc, 50, 90,
|
||||
rtl_txt, strlen(rtl_txt));
|
||||
buf[len] = 0;
|
||||
printf("'%s' %d\n", buf, keysym);
|
||||
buf[0] = 0;
|
||||
XCloseIM(xim_im);
|
||||
}
|
||||
if (filtered) {
|
||||
printf("Dead key\n");
|
||||
}
|
||||
}
|
||||
XFreeFontSet(dpy, fontset);
|
||||
return 0;
|
||||
if (xevent.type == KeyPress && !filtered) {
|
||||
len = Xutf8LookupString(xim_ic, &xevent.xkey, buf, 127, &keysym, &status);
|
||||
Xutf8DrawImageString(dpy, w, fontset, gc, x, y, buf, len);
|
||||
Xutf8DrawString(dpy, w, fontset, gc, 0, 20, jp_txt, strlen(jp_txt));
|
||||
Xutf8DrawString(dpy, w, fontset, gc, 50, 90, rtl_txt, strlen(rtl_txt));
|
||||
buf[len] = 0;
|
||||
printf("'%s' %d\n", buf, keysym);
|
||||
buf[0] = 0;
|
||||
XCloseIM(xim_im);
|
||||
}
|
||||
if (filtered) {
|
||||
printf("Dead key\n");
|
||||
}
|
||||
}
|
||||
XFreeFontSet(dpy, fontset);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -32,8 +32,8 @@
|
||||
#define conv_t void*
|
||||
#define ucs4_t unsigned int
|
||||
typedef struct {
|
||||
unsigned short indx;
|
||||
unsigned short used;
|
||||
unsigned short indx;
|
||||
unsigned short used;
|
||||
} Summary16;
|
||||
|
||||
|
||||
@@ -62,10 +62,10 @@ typedef struct {
|
||||
#include "headers/symbol_.h"
|
||||
#include "headers/dingbats_.h"
|
||||
|
||||
/*************** conv_gen.c ************/
|
||||
/*************** conv_gen.c ************/
|
||||
|
||||
/*const*/
|
||||
int ucs2fontmap(char *s, unsigned int ucs, int enc)
|
||||
{
|
||||
int ucs2fontmap(char *s, unsigned int ucs, int enc) {
|
||||
switch(enc) {
|
||||
case 0: /* iso10646-1 */
|
||||
s[0] = (char) ((ucs & 0xFF00) >> 8);
|
||||
@@ -302,8 +302,7 @@ int ucs2fontmap(char *s, unsigned int ucs, int enc)
|
||||
};
|
||||
|
||||
/*const*/
|
||||
int encoding_number(const char *enc)
|
||||
{
|
||||
int encoding_number(const char *enc) {
|
||||
if (!enc || !strncmp(enc, "iso10646-1", 10)) {
|
||||
return 0;
|
||||
} else if (!strcmp(enc, "iso8859-1")) {
|
||||
|
||||
+298
-327
File diff suppressed because it is too large
Load Diff
+162
-171
@@ -39,73 +39,69 @@
|
||||
* Returns -1 if the UTF-8 string is not valid
|
||||
*/
|
||||
int
|
||||
XConvertUtf8ToUcs(
|
||||
const unsigned char *buf,
|
||||
int len,
|
||||
unsigned int *ucs)
|
||||
{
|
||||
if (buf[0] & 0x80) {
|
||||
if (buf[0] & 0x40) {
|
||||
if (buf[0] & 0x20) {
|
||||
if (buf[0] & 0x10) {
|
||||
if (buf[0] & 0x08) {
|
||||
if (buf[0] & 0x04) {
|
||||
if (buf[0] & 0x02) {
|
||||
/* bad UTF-8 string */
|
||||
} else {
|
||||
/* 0x04000000 - 0x7FFFFFFF */
|
||||
}
|
||||
} else if (len > 4
|
||||
&& (buf[1] & 0xC0) == 0x80
|
||||
&& (buf[2] & 0xC0) == 0x80
|
||||
&& (buf[3] & 0xC0) == 0x80
|
||||
&& (buf[4] & 0xC0) == 0x80)
|
||||
{
|
||||
/* 0x00200000 - 0x03FFFFFF */
|
||||
*ucs = ((buf[0] & ~0xF8) << 24) +
|
||||
((buf[1] & ~0x80) << 18) +
|
||||
((buf[2] & ~0x80) << 12) +
|
||||
((buf[3] & ~0x80) << 6) +
|
||||
(buf[4] & ~0x80);
|
||||
if (*ucs > 0x001FFFFF && *ucs < 0x01000000) return 5;
|
||||
}
|
||||
} else if (len > 3
|
||||
&& (buf[1] & 0xC0) == 0x80
|
||||
&& (buf[2] & 0xC0) == 0x80
|
||||
&& (buf[3] & 0xC0) == 0x80)
|
||||
{
|
||||
/* 0x00010000 - 0x001FFFFF */
|
||||
*ucs = ((buf[0] & ~0xF0) << 18) +
|
||||
((buf[1] & ~0x80) << 12) +
|
||||
((buf[2] & ~0x80) << 6) +
|
||||
(buf[3] & ~0x80);
|
||||
if (*ucs > 0x0000FFFF) return 4;
|
||||
}
|
||||
} else if (len > 2 &&
|
||||
(buf[1] & 0xC0) == 0x80 &&
|
||||
(buf[2] & 0xC0) == 0x80)
|
||||
{
|
||||
/* 0x00000800 - 0x0000FFFF */
|
||||
*ucs = ((buf[0] & ~0xE0) << 12) +
|
||||
((buf[1] & ~0x80) << 6) +
|
||||
(buf[2] & ~0x80);
|
||||
if (*ucs > 0x000007FF) return 3;
|
||||
}
|
||||
} else if (len > 1 && (buf[1] & 0xC0) == 0x80) {
|
||||
/* 0x00000080 - 0x000007FF */
|
||||
*ucs = ((buf[0] & ~0xC0) << 6) +
|
||||
(buf[1] & ~0x80);
|
||||
if (*ucs > 0x0000007F) return 2;
|
||||
}
|
||||
}
|
||||
} else if (len > 0) {
|
||||
/* 0x00000000 - 0x0000007F */
|
||||
*ucs = buf[0];
|
||||
return 1;
|
||||
}
|
||||
XConvertUtf8ToUcs(const unsigned char *buf,
|
||||
int len,
|
||||
unsigned int *ucs) {
|
||||
|
||||
*ucs = (unsigned int) '?'; /* bad utf-8 string */
|
||||
return -1;
|
||||
if (buf[0] & 0x80) {
|
||||
if (buf[0] & 0x40) {
|
||||
if (buf[0] & 0x20) {
|
||||
if (buf[0] & 0x10) {
|
||||
if (buf[0] & 0x08) {
|
||||
if (buf[0] & 0x04) {
|
||||
if (buf[0] & 0x02) {
|
||||
/* bad UTF-8 string */
|
||||
} else {
|
||||
/* 0x04000000 - 0x7FFFFFFF */
|
||||
}
|
||||
} else if (len > 4
|
||||
&& (buf[1] & 0xC0) == 0x80
|
||||
&& (buf[2] & 0xC0) == 0x80
|
||||
&& (buf[3] & 0xC0) == 0x80
|
||||
&& (buf[4] & 0xC0) == 0x80) {
|
||||
/* 0x00200000 - 0x03FFFFFF */
|
||||
*ucs = ((buf[0] & ~0xF8) << 24) +
|
||||
((buf[1] & ~0x80) << 18) +
|
||||
((buf[2] & ~0x80) << 12) +
|
||||
((buf[3] & ~0x80) << 6) +
|
||||
(buf[4] & ~0x80);
|
||||
if (*ucs > 0x001FFFFF && *ucs < 0x01000000) return 5;
|
||||
}
|
||||
} else if (len > 3
|
||||
&& (buf[1] & 0xC0) == 0x80
|
||||
&& (buf[2] & 0xC0) == 0x80
|
||||
&& (buf[3] & 0xC0) == 0x80) {
|
||||
/* 0x00010000 - 0x001FFFFF */
|
||||
*ucs = ((buf[0] & ~0xF0) << 18) +
|
||||
((buf[1] & ~0x80) << 12) +
|
||||
((buf[2] & ~0x80) << 6) +
|
||||
(buf[3] & ~0x80);
|
||||
if (*ucs > 0x0000FFFF) return 4;
|
||||
}
|
||||
} else if (len > 2
|
||||
&& (buf[1] & 0xC0) == 0x80
|
||||
&& (buf[2] & 0xC0) == 0x80) {
|
||||
/* 0x00000800 - 0x0000FFFF */
|
||||
*ucs = ((buf[0] & ~0xE0) << 12) +
|
||||
((buf[1] & ~0x80) << 6) +
|
||||
(buf[2] & ~0x80);
|
||||
if (*ucs > 0x000007FF) return 3;
|
||||
}
|
||||
} else if (len > 1 && (buf[1] & 0xC0) == 0x80) {
|
||||
/* 0x00000080 - 0x000007FF */
|
||||
*ucs = ((buf[0] & ~0xC0) << 6) +
|
||||
(buf[1] & ~0x80);
|
||||
if (*ucs > 0x0000007F) return 2;
|
||||
}
|
||||
}
|
||||
} else if (len > 0) {
|
||||
/* 0x00000000 - 0x0000007F */
|
||||
*ucs = buf[0];
|
||||
return 1;
|
||||
}
|
||||
|
||||
*ucs = (unsigned int) '?'; /* bad utf-8 string */
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -113,38 +109,37 @@ XConvertUtf8ToUcs(
|
||||
* NOTE : the buffer (buf) must be at least 5 bytes long !!!
|
||||
*/
|
||||
int
|
||||
XConvertUcsToUtf8(
|
||||
unsigned int ucs,
|
||||
char *buf)
|
||||
{
|
||||
if (ucs < 0x000080) {
|
||||
buf[0] = ucs;
|
||||
return 1;
|
||||
} else if (ucs < 0x000800) {
|
||||
buf[0] = 0xC0 | (ucs >> 6);
|
||||
buf[1] = 0x80 | (ucs & 0x3F);
|
||||
return 2;
|
||||
} else if (ucs < 0x010000) {
|
||||
buf[0] = 0xE0 | (ucs >> 12);
|
||||
buf[1] = 0x80 | ((ucs >> 6) & 0x3F);
|
||||
buf[2] = 0x80 | (ucs & 0x3F);
|
||||
return 3;
|
||||
} else if (ucs < 0x00200000) {
|
||||
buf[0] = 0xF0 | (ucs >> 18);
|
||||
buf[1] = 0x80 | ((ucs >> 12) & 0x3F);
|
||||
buf[2] = 0x80 | ((ucs >> 6) & 0x3F);
|
||||
buf[3] = 0x80 | (ucs & 0x3F);
|
||||
return 4;
|
||||
} else if (ucs < 0x01000000) {
|
||||
buf[0] = 0xF8 | (ucs >> 24);
|
||||
buf[1] = 0x80 | ((ucs >> 18) & 0x3F);
|
||||
buf[2] = 0x80 | ((ucs >> 12) & 0x3F);
|
||||
buf[3] = 0x80 | ((ucs >> 6) & 0x3F);
|
||||
buf[4] = 0x80 | (ucs & 0x3F);
|
||||
return 5;
|
||||
}
|
||||
buf[0] = '?';
|
||||
return -1;
|
||||
XConvertUcsToUtf8(unsigned int ucs,
|
||||
char *buf) {
|
||||
|
||||
if (ucs < 0x000080) {
|
||||
buf[0] = ucs;
|
||||
return 1;
|
||||
} else if (ucs < 0x000800) {
|
||||
buf[0] = 0xC0 | (ucs >> 6);
|
||||
buf[1] = 0x80 | (ucs & 0x3F);
|
||||
return 2;
|
||||
} else if (ucs < 0x010000) {
|
||||
buf[0] = 0xE0 | (ucs >> 12);
|
||||
buf[1] = 0x80 | ((ucs >> 6) & 0x3F);
|
||||
buf[2] = 0x80 | (ucs & 0x3F);
|
||||
return 3;
|
||||
} else if (ucs < 0x00200000) {
|
||||
buf[0] = 0xF0 | (ucs >> 18);
|
||||
buf[1] = 0x80 | ((ucs >> 12) & 0x3F);
|
||||
buf[2] = 0x80 | ((ucs >> 6) & 0x3F);
|
||||
buf[3] = 0x80 | (ucs & 0x3F);
|
||||
return 4;
|
||||
} else if (ucs < 0x01000000) {
|
||||
buf[0] = 0xF8 | (ucs >> 24);
|
||||
buf[1] = 0x80 | ((ucs >> 18) & 0x3F);
|
||||
buf[2] = 0x80 | ((ucs >> 12) & 0x3F);
|
||||
buf[3] = 0x80 | ((ucs >> 6) & 0x3F);
|
||||
buf[4] = 0x80 | (ucs & 0x3F);
|
||||
return 5;
|
||||
}
|
||||
buf[0] = '?';
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -152,92 +147,88 @@ XConvertUcsToUtf8(
|
||||
* (returns -1 if not valid)
|
||||
*/
|
||||
int
|
||||
XUtf8CharByteLen(
|
||||
const unsigned char *buf,
|
||||
int len)
|
||||
{
|
||||
unsigned int ucs;
|
||||
return XConvertUtf8ToUcs(buf, len, &ucs);
|
||||
XUtf8CharByteLen(const unsigned char *buf,
|
||||
int len) {
|
||||
unsigned int ucs;
|
||||
return XConvertUtf8ToUcs(buf, len, &ucs);
|
||||
}
|
||||
|
||||
/*
|
||||
* returns the quantity of Unicode chars in the UTF-8 string
|
||||
*/
|
||||
int
|
||||
XCountUtf8Char(
|
||||
const unsigned char *buf,
|
||||
int len)
|
||||
{
|
||||
int i = 0;
|
||||
int nbc = 0;
|
||||
while (i < len) {
|
||||
int cl = XUtf8CharByteLen(buf + i, len - i);
|
||||
if (cl < 1) cl = 1;
|
||||
nbc++;
|
||||
i += cl;
|
||||
}
|
||||
return nbc;
|
||||
XCountUtf8Char(const unsigned char *buf,
|
||||
int len) {
|
||||
|
||||
int i = 0;
|
||||
int nbc = 0;
|
||||
while (i < len) {
|
||||
int cl = XUtf8CharByteLen(buf + i, len - i);
|
||||
if (cl < 1) cl = 1;
|
||||
nbc++;
|
||||
i += cl;
|
||||
}
|
||||
return nbc;
|
||||
}
|
||||
|
||||
/*
|
||||
* Same as XConvertUtf8ToUcs but no sanity check is done.
|
||||
*/
|
||||
int
|
||||
XFastConvertUtf8ToUcs(
|
||||
const unsigned char *buf,
|
||||
int len,
|
||||
unsigned int *ucs)
|
||||
{
|
||||
if (buf[0] & 0x80) {
|
||||
if (buf[0] & 0x40) {
|
||||
if (buf[0] & 0x20) {
|
||||
if (buf[0] & 0x10) {
|
||||
if (buf[0] & 0x08) {
|
||||
if (buf[0] & 0x04) {
|
||||
if (buf[0] & 0x02) {
|
||||
/* bad UTF-8 string */
|
||||
} else {
|
||||
/* 0x04000000 - 0x7FFFFFFF */
|
||||
}
|
||||
} else if (len > 4) {
|
||||
/* 0x00200000 - 0x03FFFFFF */
|
||||
*ucs = ((buf[0] & ~0xF8) << 24) +
|
||||
((buf[1] & ~0x80) << 18) +
|
||||
((buf[2] & ~0x80) << 12) +
|
||||
((buf[3] & ~0x80) << 6) +
|
||||
(buf[4] & ~0x80);
|
||||
return 5;
|
||||
}
|
||||
} else if (len > 3) {
|
||||
/* 0x00010000 - 0x001FFFFF */
|
||||
*ucs = ((buf[0] & ~0xF0) << 18) +
|
||||
((buf[1] & ~0x80) << 12) +
|
||||
((buf[2] & ~0x80) << 6) +
|
||||
(buf[3] & ~0x80);
|
||||
return 4;
|
||||
}
|
||||
} else if (len > 2) {
|
||||
/* 0x00000800 - 0x0000FFFF */
|
||||
*ucs = ((buf[0] & ~0xE0) << 12) +
|
||||
((buf[1] & ~0x80) << 6) +
|
||||
(buf[2] & ~0x80);
|
||||
return 3;
|
||||
}
|
||||
} else if (len > 1) {
|
||||
/* 0x00000080 - 0x000007FF */
|
||||
*ucs = ((buf[0] & ~0xC0) << 6) +
|
||||
(buf[1] & ~0x80);
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
} else if (len > 0) {
|
||||
/* 0x00000000 - 0x0000007F */
|
||||
*ucs = buf[0];
|
||||
return 1;
|
||||
}
|
||||
XFastConvertUtf8ToUcs(const unsigned char *buf,
|
||||
int len,
|
||||
unsigned int *ucs) {
|
||||
|
||||
*ucs = (unsigned int) '?'; /* bad utf-8 string */
|
||||
return -1;
|
||||
if (buf[0] & 0x80) {
|
||||
if (buf[0] & 0x40) {
|
||||
if (buf[0] & 0x20) {
|
||||
if (buf[0] & 0x10) {
|
||||
if (buf[0] & 0x08) {
|
||||
if (buf[0] & 0x04) {
|
||||
if (buf[0] & 0x02) {
|
||||
/* bad UTF-8 string */
|
||||
} else {
|
||||
/* 0x04000000 - 0x7FFFFFFF */
|
||||
}
|
||||
} else if (len > 4) {
|
||||
/* 0x00200000 - 0x03FFFFFF */
|
||||
*ucs = ((buf[0] & ~0xF8) << 24) +
|
||||
((buf[1] & ~0x80) << 18) +
|
||||
((buf[2] & ~0x80) << 12) +
|
||||
((buf[3] & ~0x80) << 6) +
|
||||
(buf[4] & ~0x80);
|
||||
return 5;
|
||||
}
|
||||
} else if (len > 3) {
|
||||
/* 0x00010000 - 0x001FFFFF */
|
||||
*ucs = ((buf[0] & ~0xF0) << 18) +
|
||||
((buf[1] & ~0x80) << 12) +
|
||||
((buf[2] & ~0x80) << 6) +
|
||||
(buf[3] & ~0x80);
|
||||
return 4;
|
||||
}
|
||||
} else if (len > 2) {
|
||||
/* 0x00000800 - 0x0000FFFF */
|
||||
*ucs = ((buf[0] & ~0xE0) << 12) +
|
||||
((buf[1] & ~0x80) << 6) +
|
||||
(buf[2] & ~0x80);
|
||||
return 3;
|
||||
}
|
||||
} else if (len > 1) {
|
||||
/* 0x00000080 - 0x000007FF */
|
||||
*ucs = ((buf[0] & ~0xC0) << 6) +
|
||||
(buf[1] & ~0x80);
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
} else if (len > 0) {
|
||||
/* 0x00000000 - 0x0000007F */
|
||||
*ucs = buf[0];
|
||||
return 1;
|
||||
}
|
||||
|
||||
*ucs = (unsigned int) '?'; /* bad utf-8 string */
|
||||
return -1;
|
||||
}
|
||||
|
||||
#endif /* X11 only */
|
||||
|
||||
+682
-717
File diff suppressed because it is too large
Load Diff
+132
-136
@@ -30,147 +30,143 @@
|
||||
#include <stdio.h>
|
||||
char buffer[1000000];
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
char buf[80];
|
||||
int len;
|
||||
char *encode[256];
|
||||
int encode_number = 0;
|
||||
unsigned int i = 0;
|
||||
unsigned char *ptr;
|
||||
unsigned char *lst = "";
|
||||
size_t nb;
|
||||
int nbb = 0;
|
||||
len = fread(buffer, 1, 1000000, stdin);
|
||||
int main(int argc, char **argv) {
|
||||
char buf[80];
|
||||
int len;
|
||||
char *encode[256];
|
||||
int encode_number = 0;
|
||||
unsigned int i = 0;
|
||||
unsigned char *ptr;
|
||||
unsigned char *lst = "";
|
||||
size_t nb;
|
||||
int nbb = 0;
|
||||
len = fread(buffer, 1, 1000000, stdin);
|
||||
|
||||
puts(" ");
|
||||
puts(" /*************** conv_gen.c ************/");
|
||||
buffer[len] = '\0';
|
||||
ptr = buffer;
|
||||
|
||||
printf("const int ucs2fontmap"
|
||||
"(char *s, unsigned int ucs, int enc)\n");
|
||||
printf("{\n");
|
||||
printf(" switch(enc) {\n");
|
||||
printf(" case 0:\n");
|
||||
printf(" s[0] = (char) ((ucs & 0xFF00) >> 8);\n");
|
||||
printf(" s[1] = (char) (ucs & 0xFF);\n");
|
||||
printf(" return 0;");
|
||||
while (len > 0) {
|
||||
unsigned char *p = ptr;
|
||||
unsigned char *f, *t;
|
||||
|
||||
while (*p != ']') {
|
||||
i++;
|
||||
p++;
|
||||
}
|
||||
*(p - 1) = '\0';
|
||||
*(p - 6) = '\0';
|
||||
f = p - 5;
|
||||
while (*p != '+') { i++; p++;}
|
||||
p++;
|
||||
t = p;
|
||||
*(p + 4) = '\0';
|
||||
if (strcmp(lst, ptr)) {
|
||||
encode_number++;
|
||||
encode[encode_number] = ptr;
|
||||
printf("\n break;");
|
||||
printf("\n case %d:\n", encode_number);
|
||||
printf(" ");
|
||||
} else {
|
||||
printf(" else ");
|
||||
}
|
||||
lst = ptr;
|
||||
printf("if (ucs <= 0x%s) {\n", t);
|
||||
printf(" if (ucs >= 0x%s) {\n", f);
|
||||
if (*(f - 3) == '2') {
|
||||
printf(" int i = (ucs - 0x%s) * 2;\n", f);
|
||||
printf(" s[0] = %s_%s[i++];\n", ptr, f, f);
|
||||
printf(" s[1] = %s_%s[i];\n", ptr, f, f);
|
||||
printf(" if (s[0] || s[1]) return %d;\n",
|
||||
encode_number);
|
||||
} else {
|
||||
printf(" s[0] = 0;\n");
|
||||
printf(" s[1] = %s_%s[ucs - 0x%s];\n",
|
||||
ptr, f, f);
|
||||
printf(" if (s[1]) return %d;\n", encode_number);
|
||||
}
|
||||
printf(" }\n");
|
||||
printf(" }");
|
||||
while (*ptr != '\n') {
|
||||
ptr++;
|
||||
len--;
|
||||
}
|
||||
ptr++;
|
||||
len--;
|
||||
}
|
||||
printf("\n break;\n");
|
||||
printf("\n default:\n");
|
||||
printf(" break;\n");
|
||||
printf(" };\n");
|
||||
printf(" return -1;\n");
|
||||
printf("};\n\n");
|
||||
puts(" ");
|
||||
puts(" /*************** conv_gen.c ************/");
|
||||
buffer[len] = '\0';
|
||||
ptr = buffer;
|
||||
|
||||
printf("const int ucs2fontmap"
|
||||
"(char *s, unsigned int ucs, int enc)\n");
|
||||
printf("{\n");
|
||||
printf(" switch(enc) {\n");
|
||||
printf(" case 0:\n");
|
||||
printf(" s[0] = (char) ((ucs & 0xFF00) >> 8);\n");
|
||||
printf(" s[1] = (char) (ucs & 0xFF);\n");
|
||||
printf(" return 0;");
|
||||
while (len > 0) {
|
||||
unsigned char *p = ptr;
|
||||
unsigned char *f, *t;
|
||||
|
||||
while (*p != ']') {
|
||||
i++;
|
||||
p++;
|
||||
}
|
||||
*(p - 1) = '\0';
|
||||
*(p - 6) = '\0';
|
||||
f = p - 5;
|
||||
while (*p != '+') { i++; p++;}
|
||||
p++;
|
||||
t = p;
|
||||
*(p + 4) = '\0';
|
||||
if (strcmp(lst, ptr)) {
|
||||
encode_number++;
|
||||
encode[encode_number] = ptr;
|
||||
printf("\n break;");
|
||||
printf("\n case %d:\n", encode_number);
|
||||
printf(" ");
|
||||
} else {
|
||||
printf(" else ");
|
||||
}
|
||||
lst = ptr;
|
||||
printf("if (ucs <= 0x%s) {\n", t);
|
||||
printf(" if (ucs >= 0x%s) {\n", f);
|
||||
if (*(f - 3) == '2') {
|
||||
printf(" int i = (ucs - 0x%s) * 2;\n", f);
|
||||
printf(" s[0] = %s_%s[i++];\n", ptr, f, f);
|
||||
printf(" s[1] = %s_%s[i];\n", ptr, f, f);
|
||||
printf(" if (s[0] || s[1]) return %d;\n", encode_number);
|
||||
} else {
|
||||
printf(" s[0] = 0;\n");
|
||||
printf(" s[1] = %s_%s[ucs - 0x%s];\n", ptr, f, f);
|
||||
printf(" if (s[1]) return %d;\n", encode_number);
|
||||
}
|
||||
printf(" }\n");
|
||||
printf(" }");
|
||||
while (*ptr != '\n') {
|
||||
ptr++;
|
||||
len--;
|
||||
}
|
||||
ptr++;
|
||||
len--;
|
||||
}
|
||||
printf("\n break;\n");
|
||||
printf("\n default:\n");
|
||||
printf(" break;\n");
|
||||
printf(" };\n");
|
||||
printf(" return -1;\n");
|
||||
printf("};\n\n");
|
||||
|
||||
printf("const int encoding_number(const char *enc)\n{\n");
|
||||
printf(" if (!enc || !strcmp(enc, \"iso10646-1\")) {\n");
|
||||
printf(" return 0;\n");
|
||||
i = 1;
|
||||
while (i <= encode_number) {
|
||||
int l;
|
||||
char *ptr;
|
||||
l = strlen(encode[i]) - 3;
|
||||
ptr = encode[i] + l;
|
||||
*(ptr) = '\0';
|
||||
ptr--;
|
||||
while (ptr != encode[i]) {
|
||||
if (*ptr == '_') {
|
||||
*ptr = '-';
|
||||
ptr--;
|
||||
break;
|
||||
}
|
||||
ptr--;
|
||||
}
|
||||
while (ptr != encode[i]) {
|
||||
if (*ptr == '_') {
|
||||
*ptr = '.';
|
||||
}
|
||||
ptr--;
|
||||
}
|
||||
printf(" } else if (!strcmp(enc, \"%s\")", encode[i] +11);
|
||||
printf("const int encoding_number(const char *enc)\n{\n");
|
||||
printf(" if (!enc || !strcmp(enc, \"iso10646-1\")) {\n");
|
||||
printf(" return 0;\n");
|
||||
i = 1;
|
||||
while (i <= encode_number) {
|
||||
int l;
|
||||
char *ptr;
|
||||
l = strlen(encode[i]) - 3;
|
||||
ptr = encode[i] + l;
|
||||
*(ptr) = '\0';
|
||||
ptr--;
|
||||
while (ptr != encode[i]) {
|
||||
if (*ptr == '_') {
|
||||
*ptr = '-';
|
||||
ptr--;
|
||||
break;
|
||||
}
|
||||
ptr--;
|
||||
}
|
||||
while (ptr != encode[i]) {
|
||||
if (*ptr == '_') {
|
||||
*ptr = '.';
|
||||
}
|
||||
ptr--;
|
||||
}
|
||||
printf(" } else if (!strcmp(enc, \"%s\")", encode[i] +11);
|
||||
|
||||
if (!strcmp(encode[i] + 11, "big5-0")) {
|
||||
printf(" || !strcmp(enc, \"big5.eten-0\")");
|
||||
} else if (!strcmp(encode[i] + 11, "dingbats")) {
|
||||
printf(" || !strcmp(enc, \"zapfdingbats\")");
|
||||
printf(" || !strcmp(enc, \"zapf dingbats\")");
|
||||
printf(" || !strcmp(enc, \"itc zapf dingbats\")");
|
||||
} else if (!strcmp(encode[i] + 11, "jisx0208.1983-0")) {
|
||||
printf(" || !strcmp(enc, \"jisx0208.1990-0\")");
|
||||
}
|
||||
if (!strcmp(encode[i] + 11, "big5-0")) {
|
||||
printf(" || !strcmp(enc, \"big5.eten-0\")");
|
||||
} else if (!strcmp(encode[i] + 11, "dingbats")) {
|
||||
printf(" || !strcmp(enc, \"zapfdingbats\")");
|
||||
printf(" || !strcmp(enc, \"zapf dingbats\")");
|
||||
printf(" || !strcmp(enc, \"itc zapf dingbats\")");
|
||||
} else if (!strcmp(encode[i] + 11, "jisx0208.1983-0")) {
|
||||
printf(" || !strcmp(enc, \"jisx0208.1990-0\")");
|
||||
}
|
||||
|
||||
printf(") {\n");
|
||||
printf(" return %d;\n", i);
|
||||
i++;
|
||||
}
|
||||
printf(" };\n");
|
||||
printf(" return -1;\n");
|
||||
printf("};\n\n");
|
||||
printf(") {\n");
|
||||
printf(" return %d;\n", i);
|
||||
i++;
|
||||
}
|
||||
printf(" };\n");
|
||||
printf(" return -1;\n");
|
||||
printf("};\n\n");
|
||||
|
||||
|
||||
printf("/*\n");
|
||||
printf("const char *encoding_name(int num)\n{\n");
|
||||
printf(" switch (num) {\n");
|
||||
i = 1;
|
||||
while (i <= encode_number) {
|
||||
printf(" case %d:\n", i);
|
||||
printf(" return \"%s\";\n", encode[i] + 11);
|
||||
i++;
|
||||
}
|
||||
printf(" };\n");
|
||||
printf(" return \"iso10646-1\";\n");
|
||||
printf("};\n\n");
|
||||
printf("*/\n");
|
||||
return 0;
|
||||
printf("/*\n");
|
||||
printf("const char *encoding_name(int num)\n{\n");
|
||||
printf(" switch (num) {\n");
|
||||
i = 1;
|
||||
while (i <= encode_number) {
|
||||
printf(" case %d:\n", i);
|
||||
printf(" return \"%s\";\n", encode[i] + 11);
|
||||
i++;
|
||||
}
|
||||
printf(" };\n");
|
||||
printf(" return \"iso10646-1\";\n");
|
||||
printf("};\n\n");
|
||||
printf("*/\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
+128
-132
@@ -33,149 +33,145 @@
|
||||
|
||||
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 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 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 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 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);
|
||||
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--;
|
||||
}
|
||||
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;
|
||||
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;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
+101
-78
@@ -1,3 +1,28 @@
|
||||
/* "$Id: $"
|
||||
*
|
||||
* Author: Jean-Marc Lienher ( http://oksid.ch )
|
||||
* Copyright 2000-2003 by O'ksi'D.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA.
|
||||
*
|
||||
* Please report all bugs and problems on the following page:
|
||||
*
|
||||
* http://www.fltk.org/str.php
|
||||
*/
|
||||
|
||||
#include <wchar.h>
|
||||
#include <stdio.h>
|
||||
char buffer[1000000];
|
||||
@@ -5,85 +30,83 @@ char buffer[1000000];
|
||||
/*** you can try to modifie this value to have better performences **/
|
||||
#define MAX_DELTA 0x80
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
char buf[80];
|
||||
int len;
|
||||
unsigned int i = 0;
|
||||
unsigned char *ptr;
|
||||
size_t nb;
|
||||
int nbb = 0;
|
||||
len = fread(buffer, 1, 1000000, stdin);
|
||||
int main(int argc, char **argv) {
|
||||
char buf[80];
|
||||
int len;
|
||||
unsigned int i = 0;
|
||||
unsigned char *ptr;
|
||||
size_t nb;
|
||||
int nbb = 0;
|
||||
len = fread(buffer, 1, 1000000, stdin);
|
||||
|
||||
buffer[len] = '\0';
|
||||
ptr = (unsigned char *)buffer;
|
||||
while (*ptr != '\n') ptr++;
|
||||
ptr++;
|
||||
while (*ptr != '\n') {
|
||||
if (*ptr == ',') nbb++;
|
||||
ptr++;
|
||||
buffer[len] = '\0';
|
||||
ptr = (unsigned char *)buffer;
|
||||
while (*ptr != '\n') ptr++;
|
||||
ptr++;
|
||||
while (*ptr != '\n') {
|
||||
if (*ptr == ',') nbb++;
|
||||
ptr++;
|
||||
}
|
||||
ptr = (unsigned char *)buffer;
|
||||
printf("/* %s */\n", argv[1]);
|
||||
while (len > 0) {
|
||||
unsigned int ucs = 0;
|
||||
char *p = ptr;
|
||||
char pp[20];
|
||||
nb = 0;
|
||||
pp[0] = '\0';
|
||||
while (*p != 'U') p++;
|
||||
strncat(pp, p, 6);
|
||||
*pp = '0';
|
||||
*(pp+1) = 'x';
|
||||
ucs = (unsigned int)strtoul(pp, NULL, 16);;
|
||||
if (ucs < 1) {
|
||||
printf("ERROR %d %d\n", len, ucs);
|
||||
abort();
|
||||
}
|
||||
if (i != ucs - 1 || !i) {
|
||||
if ((ucs - i) > MAX_DELTA || !i) {
|
||||
if (i) {
|
||||
printf("};\n");
|
||||
fprintf(stderr, "\t/* end: U+%04X */\n", i);
|
||||
}
|
||||
ptr = (unsigned char *)buffer;
|
||||
printf("/* %s */\n", argv[1]);
|
||||
while (len > 0) {
|
||||
unsigned int ucs = 0;
|
||||
char *p = ptr;
|
||||
char pp[20];
|
||||
nb = 0;
|
||||
pp[0] = '\0';
|
||||
while (*p != 'U') p++;
|
||||
strncat(pp, p, 6);
|
||||
*pp = '0';
|
||||
*(pp+1) = 'x';
|
||||
ucs = (unsigned int)strtoul(pp, NULL, 16);;
|
||||
if (ucs < 1) {
|
||||
printf("ERROR %d %d\n", len, ucs);
|
||||
abort();
|
||||
}
|
||||
if (i != ucs - 1 || !i) {
|
||||
if ((ucs - i) > MAX_DELTA || !i) {
|
||||
if (i) {
|
||||
printf("};\n");
|
||||
fprintf(stderr, "\t/* end: U+%04X */\n",
|
||||
i);
|
||||
}
|
||||
if (strcmp(argv[1], "spacing")) {
|
||||
printf("\nstatic const char"
|
||||
" unicode_to_%s_%db_%04X[]"
|
||||
" = {\n", argv[1], nbb, ucs);
|
||||
fprintf(stderr,
|
||||
"unicode_to_%s_%db_%04X[]; ",
|
||||
argv[1], nbb, ucs);
|
||||
} else {
|
||||
printf("\nstatic const unsigned short"
|
||||
" ucs_table_%04X[]"
|
||||
" = {\n", ucs);
|
||||
fprintf(stderr,
|
||||
"ucs_table_%04X[]; ",
|
||||
ucs);
|
||||
}
|
||||
} else {
|
||||
while (i < ucs - 1) {
|
||||
i++;
|
||||
if (nbb == 1) {
|
||||
printf("0x00,\n");
|
||||
} else {
|
||||
printf("0x00, 0x00,\n");
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
i = ucs;
|
||||
while (*ptr != '\n') {
|
||||
printf("%c", *ptr);
|
||||
ptr++;
|
||||
len--;
|
||||
}
|
||||
printf("\n");
|
||||
ptr++;
|
||||
len--;
|
||||
if (strcmp(argv[1], "spacing")) {
|
||||
printf("\nstatic const char unicode_to_%s_%db_%04X[] = {\n",
|
||||
argv[1], nbb, ucs);
|
||||
fprintf(stderr, "unicode_to_%s_%db_%04X[]; ",
|
||||
argv[1], nbb, ucs);
|
||||
} else {
|
||||
printf("\nstatic const unsigned short"
|
||||
" ucs_table_%04X[]"
|
||||
" = {\n", ucs);
|
||||
fprintf(stderr, "ucs_table_%04X[]; ", ucs);
|
||||
}
|
||||
printf("};\n");
|
||||
fprintf(stderr, "\t/* end: U+%04X */\n", i);
|
||||
return 0;
|
||||
} else {
|
||||
while (i < ucs - 1) {
|
||||
i++;
|
||||
if (nbb == 1) {
|
||||
printf("0x00,\n");
|
||||
} else {
|
||||
printf("0x00, 0x00,\n");
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
i = ucs;
|
||||
while (*ptr != '\n') {
|
||||
printf("%c", *ptr);
|
||||
ptr++;
|
||||
len--;
|
||||
}
|
||||
printf("\n");
|
||||
ptr++;
|
||||
len--;
|
||||
}
|
||||
printf("};\n");
|
||||
fprintf(stderr, "\t/* end: U+%04X */\n", i);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* End of "$Id$".
|
||||
*/
|
||||
|
||||
+26
-28
@@ -32,36 +32,34 @@
|
||||
char uni[0x10000];
|
||||
#include "../utf8Utils.c"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
iconv_t cd;
|
||||
iconv_t cd;
|
||||
|
||||
int i;
|
||||
cd = iconv_open("EUC-TW", "UTF16");
|
||||
for(i = 0; i < 0x10000; i++) uni[i] = 0;
|
||||
for(i = 0x00000000; i < 0xFFFFFFFF; i++) {
|
||||
char buf[4], ob[6];
|
||||
char *b = buf;
|
||||
int ucs = -1;
|
||||
int l1 = 4, l2 = 6;
|
||||
char *o = ob ;
|
||||
buf[0] = i & 0xff;
|
||||
buf[1] = (i >> 8) & 0xFF;
|
||||
buf[2] = (i >> 16) & 0xFF;
|
||||
buf[3] = (i >> 24) & 0xFF;
|
||||
iconv(cd, NULL, NULL, NULL, NULL);
|
||||
iconv(cd, &b, &l1, &o, &l2);
|
||||
if (l2 != 6) {
|
||||
ucs = (unsigned)ob[0];
|
||||
ucs += (unsigned) (ob[1] << 8);
|
||||
//XConvertUtf8ToUcs((unsigned char*)ob, 6 - l2, &ucs);
|
||||
printf ("%x --> %X\n", i, ucs & 0xFFFF);
|
||||
}
|
||||
|
||||
}
|
||||
iconv_close(cd);
|
||||
return 0;
|
||||
int i;
|
||||
cd = iconv_open("EUC-TW", "UTF16");
|
||||
for(i = 0; i < 0x10000; i++) uni[i] = 0;
|
||||
for(i = 0x00000000; i < 0xFFFFFFFF; i++) {
|
||||
char buf[4], ob[6];
|
||||
char *b = buf;
|
||||
int ucs = -1;
|
||||
int l1 = 4, l2 = 6;
|
||||
char *o = ob ;
|
||||
buf[0] = i & 0xff;
|
||||
buf[1] = (i >> 8) & 0xFF;
|
||||
buf[2] = (i >> 16) & 0xFF;
|
||||
buf[3] = (i >> 24) & 0xFF;
|
||||
iconv(cd, NULL, NULL, NULL, NULL);
|
||||
iconv(cd, &b, &l1, &o, &l2);
|
||||
if (l2 != 6) {
|
||||
ucs = (unsigned)ob[0];
|
||||
ucs += (unsigned) (ob[1] << 8);
|
||||
//XConvertUtf8ToUcs((unsigned char*)ob, 6 - l2, &ucs);
|
||||
printf ("%x --> %X\n", i, ucs & 0xFFFF);
|
||||
}
|
||||
}
|
||||
iconv_close(cd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user