mirror of
https://github.com/fltk/fltk.git
synced 2026-05-28 11:25:22 +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 "headers/case.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
XUtf8Tolower(
|
XUtf8Tolower(int ucs) {
|
||||||
int ucs)
|
int ret;
|
||||||
{
|
if (ucs <= 0x02B6) {
|
||||||
int ret;
|
if (ucs >= 0x0041) {
|
||||||
|
ret = ucs_table_0041[ucs - 0x0041];
|
||||||
|
if (ret > 0) return ret;
|
||||||
|
}
|
||||||
|
return ucs;
|
||||||
|
}
|
||||||
|
|
||||||
if (ucs <= 0x02B6) {
|
if (ucs <= 0x0556) {
|
||||||
if (ucs >= 0x0041) {
|
if (ucs >= 0x0386) {
|
||||||
ret = ucs_table_0041[ucs - 0x0041];
|
ret = ucs_table_0386[ucs - 0x0386];
|
||||||
if (ret > 0) return ret;
|
if (ret > 0) return ret;
|
||||||
}
|
}
|
||||||
return ucs;
|
return ucs;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ucs <= 0x0556) {
|
if (ucs <= 0x10C5) {
|
||||||
if (ucs >= 0x0386) {
|
if (ucs >= 0x10A0) {
|
||||||
ret = ucs_table_0386[ucs - 0x0386];
|
ret = ucs_table_10A0[ucs - 0x10A0];
|
||||||
if (ret > 0) return ret;
|
if (ret > 0) return ret;
|
||||||
}
|
}
|
||||||
return ucs;
|
return ucs;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ucs <= 0x10C5) {
|
if (ucs <= 0x1FFC) {
|
||||||
if (ucs >= 0x10A0) {
|
if (ucs >= 0x1E00) {
|
||||||
ret = ucs_table_10A0[ucs - 0x10A0];
|
ret = ucs_table_1E00[ucs - 0x1E00];
|
||||||
if (ret > 0) return ret;
|
if (ret > 0) return ret;
|
||||||
}
|
}
|
||||||
return ucs;
|
return ucs;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ucs <= 0x1FFC) {
|
if (ucs <= 0x2133) {
|
||||||
if (ucs >= 0x1E00) {
|
if (ucs >= 0x2102) {
|
||||||
ret = ucs_table_1E00[ucs - 0x1E00];
|
ret = ucs_table_2102[ucs - 0x2102];
|
||||||
if (ret > 0) return ret;
|
if (ret > 0) return ret;
|
||||||
}
|
}
|
||||||
return ucs;
|
return ucs;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ucs <= 0x2133) {
|
if (ucs <= 0x24CF) {
|
||||||
if (ucs >= 0x2102) {
|
if (ucs >= 0x24B6) {
|
||||||
ret = ucs_table_2102[ucs - 0x2102];
|
ret = ucs_table_24B6[ucs - 0x24B6];
|
||||||
if (ret > 0) return ret;
|
if (ret > 0) return ret;
|
||||||
}
|
}
|
||||||
return ucs;
|
return ucs;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ucs <= 0x24CF) {
|
if (ucs <= 0x33CE) {
|
||||||
if (ucs >= 0x24B6) {
|
if (ucs >= 0x33CE) {
|
||||||
ret = ucs_table_24B6[ucs - 0x24B6];
|
ret = ucs_table_33CE[ucs - 0x33CE];
|
||||||
if (ret > 0) return ret;
|
if (ret > 0) return ret;
|
||||||
}
|
}
|
||||||
return ucs;
|
return ucs;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ucs <= 0x33CE) {
|
if (ucs <= 0xFF3A) {
|
||||||
if (ucs >= 0x33CE) {
|
if (ucs >= 0xFF21) {
|
||||||
ret = ucs_table_33CE[ucs - 0x33CE];
|
ret = ucs_table_FF21[ucs - 0xFF21];
|
||||||
if (ret > 0) return ret;
|
if (ret > 0) return ret;
|
||||||
}
|
}
|
||||||
return ucs;
|
return ucs;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ucs <= 0xFF3A) {
|
return ucs;
|
||||||
if (ucs >= 0xFF21) {
|
|
||||||
ret = ucs_table_FF21[ucs - 0xFF21];
|
|
||||||
if (ret > 0) return ret;
|
|
||||||
}
|
|
||||||
return ucs;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ucs;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
XUtf8Toupper(
|
XUtf8Toupper(int ucs) {
|
||||||
int ucs)
|
int i;
|
||||||
{
|
static unsigned short *table = NULL;
|
||||||
int i;
|
|
||||||
static unsigned short *table = NULL;
|
|
||||||
|
|
||||||
if (!table) {
|
if (!table) {
|
||||||
table = (unsigned short*) malloc(
|
table = (unsigned short*) malloc(sizeof(unsigned short) * 0x10000);
|
||||||
sizeof(unsigned short) * 0x10000);
|
for (i = 0; i < 0x10000; i++) {
|
||||||
for (i = 0; i < 0x10000; i++) {
|
table[i] = (unsigned short) i;
|
||||||
table[i] = (unsigned short) i;
|
}
|
||||||
}
|
for (i = 0; i < 0x10000; i++) {
|
||||||
for (i = 0; i < 0x10000; i++) {
|
int l;
|
||||||
int l;
|
l = XUtf8Tolower(i);
|
||||||
l = XUtf8Tolower(i);
|
if (l != i) table[l] = (unsigned short) i;
|
||||||
if (l != i) table[l] = (unsigned short) i;
|
}
|
||||||
}
|
}
|
||||||
|
if (ucs >= 0x10000 || ucs < 0) return ucs;
|
||||||
}
|
return table[ucs];
|
||||||
if (ucs >= 0x10000 || ucs < 0) return ucs;
|
|
||||||
return table[ucs];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* End of "$Id$".
|
* End of "$Id$".
|
||||||
*/
|
*/
|
||||||
|
|||||||
+38
-40
@@ -28,57 +28,55 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
unsigned short
|
unsigned short
|
||||||
XUtf8IsRightToLeft(
|
XUtf8IsRightToLeft(unsigned int ucs) {
|
||||||
unsigned int ucs)
|
|
||||||
{
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
/* for debug only */
|
/* for debug only */
|
||||||
if (ucs <= 0x005A) {
|
if (ucs <= 0x005A) {
|
||||||
if (ucs >= 0x0041) return 1;
|
if (ucs >= 0x0041) return 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* HEBREW */
|
/* HEBREW */
|
||||||
if (ucs <= 0x05F4) {
|
if (ucs <= 0x05F4) {
|
||||||
if (ucs >= 0x0591) return 1;
|
if (ucs >= 0x0591) return 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ARABIC */
|
/* ARABIC */
|
||||||
if (ucs <= 0x06ED) {
|
if (ucs <= 0x06ED) {
|
||||||
if (ucs >= 0x060C) return 1;
|
if (ucs >= 0x060C) return 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ucs <= 0x06F9) {
|
if (ucs <= 0x06F9) {
|
||||||
if (ucs >= 0x06F0) return 1;
|
if (ucs >= 0x06F0) return 1;
|
||||||
return 0;
|
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 <= 0xFB4F) {
|
||||||
if (ucs >= 0xFB1E) return 1;
|
if (ucs >= 0xFB1E) return 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ucs <= 0xFDFB) {
|
if (ucs <= 0xFDFB) {
|
||||||
if (ucs >= 0xFB50) return 1;
|
if (ucs >= 0xFB50) return 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ucs <= 0xFEFC) {
|
if (ucs <= 0xFEFC) {
|
||||||
if (ucs >= 0xFE70) return 1;
|
if (ucs >= 0xFE70) return 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
+42
-45
@@ -29,63 +29,60 @@
|
|||||||
|
|
||||||
#include "headers/spacing.h"
|
#include "headers/spacing.h"
|
||||||
|
|
||||||
|
|
||||||
unsigned short
|
unsigned short
|
||||||
XUtf8IsNonSpacing(
|
XUtf8IsNonSpacing(unsigned int ucs) {
|
||||||
unsigned int ucs)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (ucs <= 0x0361) {
|
if (ucs <= 0x0361) {
|
||||||
if (ucs >= 0x0300) return ucs_table_0300[ucs - 0x0300];
|
if (ucs >= 0x0300) return ucs_table_0300[ucs - 0x0300];
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ucs <= 0x0486) {
|
if (ucs <= 0x0486) {
|
||||||
if (ucs >= 0x0483) return ucs_table_0483[ucs - 0x0483];
|
if (ucs >= 0x0483) return ucs_table_0483[ucs - 0x0483];
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ucs <= 0x05C4) {
|
if (ucs <= 0x05C4) {
|
||||||
if (ucs >= 0x0591) return ucs_table_0591[ucs - 0x0591];
|
if (ucs >= 0x0591) return ucs_table_0591[ucs - 0x0591];
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ucs <= 0x06ED) {
|
if (ucs <= 0x06ED) {
|
||||||
if (ucs >= 0x064B) return ucs_table_064B[ucs - 0x064B];
|
if (ucs >= 0x064B) return ucs_table_064B[ucs - 0x064B];
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ucs <= 0x0D4D) {
|
if (ucs <= 0x0D4D) {
|
||||||
if (ucs >= 0x0901) return ucs_table_0901[ucs - 0x0901];
|
if (ucs >= 0x0901) return ucs_table_0901[ucs - 0x0901];
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ucs <= 0x0FB9) {
|
if (ucs <= 0x0FB9) {
|
||||||
if (ucs >= 0x0E31) return ucs_table_0E31[ucs - 0x0E31];
|
if (ucs >= 0x0E31) return ucs_table_0E31[ucs - 0x0E31];
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ucs <= 0x20E1) {
|
if (ucs <= 0x20E1) {
|
||||||
if (ucs >= 0x20D0) return ucs_table_20D0[ucs - 0x20D0];
|
if (ucs >= 0x20D0) return ucs_table_20D0[ucs - 0x20D0];
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ucs <= 0x309A) {
|
if (ucs <= 0x309A) {
|
||||||
if (ucs >= 0x302A) return ucs_table_302A[ucs - 0x302A];
|
if (ucs >= 0x302A) return ucs_table_302A[ucs - 0x302A];
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ucs <= 0xFB1E) {
|
if (ucs <= 0xFB1E) {
|
||||||
if (ucs >= 0xFB1E) return ucs_table_FB1E[ucs - 0xFB1E];
|
if (ucs >= 0xFB1E) return ucs_table_FB1E[ucs - 0xFB1E];
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ucs <= 0xFE23) {
|
if (ucs <= 0xFE23) {
|
||||||
if (ucs >= 0xFE20) return ucs_table_FE20[ucs - 0xFE20];
|
if (ucs >= 0xFE20) return ucs_table_FE20[ucs - 0xFE20];
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -30,10 +30,8 @@
|
|||||||
#include "../../FL/Xutf8.h"
|
#include "../../FL/Xutf8.h"
|
||||||
#include "imKStoUCS.c"
|
#include "imKStoUCS.c"
|
||||||
|
|
||||||
|
long XKeysymToUcs(KeySym keysym) {
|
||||||
long XKeysymToUcs(KeySym keysym)
|
return (long) KeySymToUcs4(keysym);
|
||||||
{
|
|
||||||
return (long) KeySymToUcs4(keysym);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* X11 only */
|
#endif /* X11 only */
|
||||||
|
|||||||
+197
-194
@@ -26,7 +26,9 @@
|
|||||||
/*
|
/*
|
||||||
* UTF-8 X test program (It contains MINIMAL code to support XIM !!!)
|
* UTF-8 X test program (It contains MINIMAL code to support XIM !!!)
|
||||||
*
|
*
|
||||||
To test it do :
|
****************
|
||||||
|
* To test it do:
|
||||||
|
****************
|
||||||
|
|
||||||
kinput2 -canna
|
kinput2 -canna
|
||||||
XMODIFIERS="@im=kinput2"; export XMODIFIERS
|
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_TW"
|
||||||
export LANG=zh_TW; export XMODIFIERS="@im=xcin-zh_CN"
|
export LANG=zh_TW; export XMODIFIERS="@im=xcin-zh_CN"
|
||||||
export LANG=C; export XMODIFIERS="@im=interxim"
|
export LANG=C; export XMODIFIERS="@im=interxim"
|
||||||
*/
|
**********************************************************/
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -80,208 +82,209 @@ GC gc;
|
|||||||
int x = 2;
|
int x = 2;
|
||||||
int y = 40;
|
int y = 40;
|
||||||
|
|
||||||
int main(int argc, char**argv)
|
int main(int argc, char**argv) {
|
||||||
{
|
char **missing_charset_list;
|
||||||
char **missing_charset_list;
|
int missing_charset_count;
|
||||||
int missing_charset_count;
|
XGCValues xgcv;
|
||||||
XGCValues xgcv;
|
unsigned long mask;
|
||||||
unsigned long mask;
|
Display* dpy;
|
||||||
Display* dpy;
|
int scr;
|
||||||
int scr;
|
Window w, root;
|
||||||
Window w, root;
|
XSetWindowAttributes set_attr;
|
||||||
XSetWindowAttributes set_attr;
|
int i;
|
||||||
int i;
|
XIMStyle *style;
|
||||||
XIMStyle *style;
|
static char buf[128];
|
||||||
static char buf[128];
|
KeySym keysym = 0;
|
||||||
KeySym keysym = 0;
|
Status status;
|
||||||
Status status;
|
XWMHints wm_hints;
|
||||||
XWMHints wm_hints;
|
XClassHint class_hints;
|
||||||
XClassHint class_hints;
|
XIMStyle input_style = 0;
|
||||||
XIMStyle input_style = 0;
|
char **font_name_list;
|
||||||
char **font_name_list;
|
char *def_string;
|
||||||
char *def_string;
|
XFontStruct **font_struct_list;
|
||||||
XFontStruct **font_struct_list;
|
char **font_encoding_list;
|
||||||
char **font_encoding_list;
|
int nb_font;
|
||||||
int nb_font;
|
int len = 0;
|
||||||
int len = 0;
|
int no_xim = 0;
|
||||||
int no_xim = 0;
|
|
||||||
|
|
||||||
printf ("A -> %c \n", XUtf8Tolower('A'));
|
printf ("A -> %c \n", XUtf8Tolower('A'));
|
||||||
if (!setlocale(LC_ALL, ""))
|
if (!setlocale(LC_ALL, ""))
|
||||||
puts("locale not supported by C library, locale unchanged");
|
puts("locale not supported by C library, locale unchanged");
|
||||||
|
|
||||||
if (!XSetLocaleModifiers(""))
|
if (!XSetLocaleModifiers(""))
|
||||||
puts("X locale modifiers not supported, using default");
|
puts("X locale modifiers not supported, using default");
|
||||||
|
|
||||||
dpy = XOpenDisplay(0);
|
dpy = XOpenDisplay(0);
|
||||||
if (!dpy) { puts("cannot open display.\n"); exit(-1); }
|
if (!dpy) { puts("cannot open display.\n"); exit(-1); }
|
||||||
scr = DefaultScreen(dpy);
|
scr = DefaultScreen(dpy);
|
||||||
root = RootWindow(dpy, scr);
|
root = RootWindow(dpy, scr);
|
||||||
set_attr.event_mask = KeyPressMask|FocusChangeMask;
|
set_attr.event_mask = KeyPressMask|FocusChangeMask;
|
||||||
set_attr.background_pixel = WhitePixel(dpy, DefaultScreen(dpy));
|
set_attr.background_pixel = WhitePixel(dpy, DefaultScreen(dpy));
|
||||||
set_attr.border_pixel = BlackPixel(dpy, DefaultScreen(dpy));
|
set_attr.border_pixel = BlackPixel(dpy, DefaultScreen(dpy));
|
||||||
w = XCreateWindow(dpy, root, 10,10,200,100,0,
|
w = XCreateWindow(dpy, root, 10,10,200,100,0,
|
||||||
DefaultDepth(dpy, DefaultScreen(dpy)),
|
DefaultDepth(dpy, DefaultScreen(dpy)),
|
||||||
InputOutput, DefaultVisual(dpy, DefaultScreen(dpy)),
|
InputOutput, DefaultVisual(dpy, DefaultScreen(dpy)),
|
||||||
CWEventMask | CWBackPixel | CWBorderPixel, &set_attr);
|
CWEventMask | CWBackPixel | CWBorderPixel, &set_attr);
|
||||||
if (!w) { puts("cannot creat window.\n"); exit(-1); }
|
if (!w) {
|
||||||
|
puts("cannot creat window.\n");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
class_hints.res_name = "test";
|
class_hints.res_name = "test";
|
||||||
class_hints.res_class = "Test";
|
class_hints.res_class = "Test";
|
||||||
wm_hints.input = True;
|
wm_hints.input = True;
|
||||||
wm_hints.flags = InputHint;
|
wm_hints.flags = InputHint;
|
||||||
|
|
||||||
XmbSetWMProperties(dpy, w, "test", "test", NULL, 0,
|
XmbSetWMProperties(dpy, w, "test", "test", NULL, 0,
|
||||||
NULL, &wm_hints, &class_hints);
|
NULL, &wm_hints, &class_hints);
|
||||||
|
|
||||||
XMapWindow(dpy, w);
|
XMapWindow(dpy, w);
|
||||||
xim_im = XOpenIM(dpy, NULL, "test", "Test");
|
xim_im = XOpenIM(dpy, NULL, "test", "Test");
|
||||||
if (!xim_im) {
|
if (!xim_im) {
|
||||||
puts("cannot Open Input Manager: Try default.\n");
|
puts("cannot Open Input Manager: Try default.\n");
|
||||||
XSetLocaleModifiers("@im=");
|
XSetLocaleModifiers("@im=");
|
||||||
xim_im = XOpenIM(dpy, NULL, "test", "Test");
|
xim_im = XOpenIM(dpy, NULL, "test", "Test");
|
||||||
if (!xim_im) { puts("Failed exiting.\n"); exit(-1); }
|
if (!xim_im) {
|
||||||
}
|
puts("Failed exiting.\n");
|
||||||
XGetIMValues (xim_im, XNQueryInputStyle, &xim_styles, NULL, NULL);
|
exit(-1);
|
||||||
for (i = 0, style = xim_styles->supported_styles;
|
}
|
||||||
i < xim_styles->count_styles; i++, style++)
|
}
|
||||||
{
|
XGetIMValues (xim_im, XNQueryInputStyle, &xim_styles, NULL, NULL);
|
||||||
if (i == 0 && *style == (XIMStatusNone|XIMPreeditNone)) {
|
for (i = 0, style = xim_styles->supported_styles;
|
||||||
printf("this is not a XIM server !!!\n");
|
i < xim_styles->count_styles; i++, style++) {
|
||||||
no_xim = 1;
|
if (i == 0 && *style == (XIMStatusNone|XIMPreeditNone)) {
|
||||||
}
|
printf("this is not a XIM server !!!\n");
|
||||||
printf("input style : 0x%X\n", *style);
|
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,
|
xim_ic = XCreateIC(xim_im,
|
||||||
XNInputStyle,
|
XNInputStyle, (XIMPreeditNothing | XIMStatusNothing),
|
||||||
(XIMPreeditNothing | XIMStatusNothing),
|
XNClientWindow, w,
|
||||||
XNClientWindow, w,
|
XNFocusWindow, w,
|
||||||
XNFocusWindow, w,
|
NULL);
|
||||||
NULL);
|
} else {
|
||||||
if (!xim_ic) { puts("cannot create Input Context.\n"); exit(-1);}
|
xim_ic = NULL;
|
||||||
XFree(xim_styles);
|
}
|
||||||
XSetICFocus(xim_ic);
|
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) {
|
||||||
/** I don't recommand to use a font base name list similar
|
len = XUtf8LookupString(xim_ic, &xevent.xkey,
|
||||||
* to the following one in a real application ;-)
|
buf, 127, &keysym, &status);
|
||||||
* 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 */
|
if (len == 1 && buf[0] == '\b') {
|
||||||
nb_font = fontset->nb_font;
|
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) {
|
XUtf8DrawString(dpy, w, fontset, gc, 0, 20, jp_txt, strlen(jp_txt));
|
||||||
nb_font--;
|
XUtf8DrawString(dpy, w, fontset, gc, 50, 90, rtl_txt, strlen(rtl_txt));
|
||||||
if (fontset->fonts[nb_font]) {
|
XUtf8DrawRtlString(dpy, w, fontset, gc, 50, 90, rtl_txt, strlen(rtl_txt));
|
||||||
printf("encoding=\"\" fid=%d \n %s\n",
|
buf[len] = 0;
|
||||||
// fontset->encodings[nb_font],
|
printf("'%s' %d %x\n", buf, keysym, keysym);
|
||||||
fontset->fonts[nb_font]->fid,
|
buf[0] = 0;
|
||||||
fontset->font_name_list[nb_font]);
|
}
|
||||||
}
|
if (filtered) {
|
||||||
}
|
printf("Dead key\n");
|
||||||
/* END OF NOT REQUIERED PART*/
|
}
|
||||||
|
}
|
||||||
mask = (GCForeground | GCBackground);
|
XFreeUtf8FontStruct(dpy, fontset);
|
||||||
xgcv.foreground = BlackPixel(dpy, DefaultScreen(dpy));
|
return 0;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
+128
-137
@@ -26,7 +26,9 @@
|
|||||||
/*
|
/*
|
||||||
* UTF-8 X test program
|
* UTF-8 X test program
|
||||||
*
|
*
|
||||||
To test it do :
|
*****************
|
||||||
|
* To test it do :
|
||||||
|
*****************
|
||||||
|
|
||||||
kinput2 -canna
|
kinput2 -canna
|
||||||
XMODIFIERS="@im=kinput2"; export XMODIFIERS
|
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>
|
#include <X11/Xmd.h>
|
||||||
|
|
||||||
char *jp_txt = "é UTF-8 e\xCC\x82=\xC3\xAA"
|
char *jp_txt = "é UTF-8 e\xCC\x82=\xC3\xAA"
|
||||||
" \357\274\270\357\274\254\357\274\246\357\274"
|
" \357\274\270\357\274\254\357\274\246\357\274"
|
||||||
"\244\345\220\215\343\201\247\346\214\207 \345\256\232"
|
"\244\345\220\215\343\201\247\346\214\207 \345\256\232"
|
||||||
"\343\201\231\343\202\213";
|
"\343\201\231\343\202\213";
|
||||||
|
|
||||||
char *rtl_txt = "->e\xCC\x82=\xC3\xAA";
|
char *rtl_txt = "->e\xCC\x82=\xC3\xAA";
|
||||||
|
|
||||||
@@ -82,149 +84,138 @@ GC gc;
|
|||||||
int x = 2;
|
int x = 2;
|
||||||
int y = 40;
|
int y = 40;
|
||||||
|
|
||||||
int main(int argc, char**argv)
|
int main(int argc, char**argv) {
|
||||||
{
|
char **missing_charset_list;
|
||||||
char **missing_charset_list;
|
int missing_charset_count;
|
||||||
int missing_charset_count;
|
XGCValues xgcv;
|
||||||
XGCValues xgcv;
|
unsigned long mask;
|
||||||
unsigned long mask;
|
Display* dpy;
|
||||||
Display* dpy;
|
int scr;
|
||||||
int scr;
|
Window w, root;
|
||||||
Window w, root;
|
XSetWindowAttributes set_attr;
|
||||||
XSetWindowAttributes set_attr;
|
int i;
|
||||||
int i;
|
XIMStyle *style;
|
||||||
XIMStyle *style;
|
static char buf[128];
|
||||||
static char buf[128];
|
KeySym keysym = 0;
|
||||||
KeySym keysym = 0;
|
Status status;
|
||||||
Status status;
|
XWMHints wm_hints;
|
||||||
XWMHints wm_hints;
|
XClassHint class_hints;
|
||||||
XClassHint class_hints;
|
XIMStyle input_style = 0;
|
||||||
XIMStyle input_style = 0;
|
char **font_name_list;
|
||||||
char **font_name_list;
|
char *def_string;
|
||||||
char *def_string;
|
XFontStruct **font_struct_list;
|
||||||
XFontStruct **font_struct_list;
|
char **font_encoding_list;
|
||||||
char **font_encoding_list;
|
int nb_font;
|
||||||
int nb_font;
|
int len = 0;
|
||||||
int len = 0;
|
int no_xim = 0;
|
||||||
int no_xim = 0;
|
char **missing_charset_list_return;
|
||||||
char **missing_charset_list_return;
|
int missing_charset_count_return;
|
||||||
int missing_charset_count_return;
|
char *def_string_return;
|
||||||
char *def_string_return;
|
|
||||||
|
if (!setlocale(LC_ALL, ""))
|
||||||
if (!setlocale(LC_ALL, ""))
|
puts("locale not supported by C library, locale unchanged");
|
||||||
puts("locale not supported by C library, locale unchanged");
|
|
||||||
|
|
||||||
if (!XSetLocaleModifiers(""))
|
if (!XSetLocaleModifiers(""))
|
||||||
puts("X locale modifiers not supported, using default");
|
puts("X locale modifiers not supported, using default");
|
||||||
|
|
||||||
dpy = XOpenDisplay(0);
|
dpy = XOpenDisplay(0);
|
||||||
scr = DefaultScreen(dpy);
|
scr = DefaultScreen(dpy);
|
||||||
root = RootWindow(dpy, scr);
|
root = RootWindow(dpy, scr);
|
||||||
set_attr.event_mask = KeyPressMask|FocusChangeMask;
|
set_attr.event_mask = KeyPressMask|FocusChangeMask;
|
||||||
set_attr.background_pixel = WhitePixel(dpy, DefaultScreen(dpy));
|
set_attr.background_pixel = WhitePixel(dpy, DefaultScreen(dpy));
|
||||||
set_attr.border_pixel = BlackPixel(dpy, DefaultScreen(dpy));
|
set_attr.border_pixel = BlackPixel(dpy, DefaultScreen(dpy));
|
||||||
w = XCreateWindow(dpy, root, 10,10,200,100,0,
|
w = XCreateWindow(dpy, root, 10,10,200,100,0,
|
||||||
DefaultDepth(dpy, DefaultScreen(dpy)),
|
DefaultDepth(dpy, DefaultScreen(dpy)),
|
||||||
InputOutput, DefaultVisual(dpy, DefaultScreen(dpy)),
|
InputOutput, DefaultVisual(dpy, DefaultScreen(dpy)),
|
||||||
CWEventMask | CWBackPixel | CWBorderPixel, &set_attr);
|
CWEventMask | CWBackPixel | CWBorderPixel, &set_attr);
|
||||||
|
|
||||||
class_hints.res_name = "test";
|
class_hints.res_name = "test";
|
||||||
class_hints.res_class = "Test";
|
class_hints.res_class = "Test";
|
||||||
wm_hints.input = True;
|
wm_hints.input = True;
|
||||||
wm_hints.flags = InputHint;
|
wm_hints.flags = InputHint;
|
||||||
|
|
||||||
XmbSetWMProperties(dpy, w, "test", "test", NULL, 0,
|
XmbSetWMProperties(dpy, w, "test", "test", NULL, 0,
|
||||||
NULL, &wm_hints, &class_hints);
|
NULL, &wm_hints, &class_hints);
|
||||||
|
|
||||||
XMapWindow(dpy, w);
|
XMapWindow(dpy, w);
|
||||||
xim_im = XOpenIM(dpy, NULL, "test", "Test");
|
xim_im = XOpenIM(dpy, NULL, "test", "Test");
|
||||||
XGetIMValues (xim_im, XNQueryInputStyle, &xim_styles, NULL, NULL);
|
XGetIMValues(xim_im, XNQueryInputStyle, &xim_styles, NULL, NULL);
|
||||||
for (i = 0, style = xim_styles->supported_styles;
|
for (i = 0, style = xim_styles->supported_styles;
|
||||||
i < xim_styles->count_styles; i++, style++)
|
i < xim_styles->count_styles; i++, style++) {
|
||||||
{
|
if (*style == (XIMStatusNone|XIMPreeditNone)) {
|
||||||
if (*style == (XIMStatusNone|XIMPreeditNone)) {
|
printf("this is not a XIM server !!!\n");
|
||||||
printf("this is not a XIM server !!!\n");
|
no_xim = 1;
|
||||||
no_xim = 1;
|
}
|
||||||
}
|
printf("input style : 0x%X\n", *style);
|
||||||
printf("input style : 0x%X\n", *style);
|
}
|
||||||
}
|
XFree(xim_styles);
|
||||||
XFree(xim_styles);
|
|
||||||
|
|
||||||
xim_ic = XCreateIC(xim_im,
|
xim_ic = XCreateIC(xim_im,
|
||||||
XNInputStyle, (XIMPreeditNothing | XIMStatusNothing),
|
XNInputStyle, (XIMPreeditNothing | XIMStatusNothing),
|
||||||
XNClientWindow, w,
|
XNClientWindow, w,
|
||||||
XNFocusWindow, w,
|
XNFocusWindow, w,
|
||||||
NULL);
|
NULL);
|
||||||
XSetICFocus(xim_ic);
|
XSetICFocus(xim_ic);
|
||||||
|
|
||||||
/***************************************************************/
|
/***************************************************************
|
||||||
/** I don't recommand to use a font base name list similar
|
* I don't recommend to use a font base name list similar
|
||||||
* to the following one in a real application ;-) */
|
* to the following one in a real application ;-)
|
||||||
/***************************************************************/
|
***************************************************************/
|
||||||
fontset = XCreateFontSet(dpy,
|
fontset = XCreateFontSet(dpy,
|
||||||
"-*-*-*-*-*-*-*-*-*-*-*-*-iso8858-3," /* not valid */
|
"-*-*-*-*-*-*-*-*-*-*-*-*-iso8858-3," /* not valid */
|
||||||
"-*-*-medium-r-*-*-*-*-*-*-*-*-iso8859-1,"
|
"-*-*-medium-r-*-*-*-*-*-*-*-*-iso8859-1,"
|
||||||
"-*-*-*-*-*-*-*-*-*-*-*-*-iso8859-6,"
|
"-*-*-*-*-*-*-*-*-*-*-*-*-iso8859-6,"
|
||||||
"-*-*-*-*-*-*-*-*-*-*-*-*-iso8859-8,"
|
"-*-*-*-*-*-*-*-*-*-*-*-*-iso8859-8,"
|
||||||
"-*-symbol-*-*-*-*-*-*-*-*-*-*-adobe-fontspecific,"
|
"-*-symbol-*-*-*-*-*-*-*-*-*-*-adobe-fontspecific,"
|
||||||
"-*-*-*-*-*-*-*-*-*-*-*-*-iso8859-2,"
|
"-*-*-*-*-*-*-*-*-*-*-*-*-iso8859-2,"
|
||||||
"-*-*-*-*-*-*-*-*-*-*-*-*-koi8-1,"
|
"-*-*-*-*-*-*-*-*-*-*-*-*-koi8-1,"
|
||||||
"-*-*-*-*-*-*-*-*-*-*-*-*-jisx0208.1983-0,"
|
"-*-*-*-*-*-*-*-*-*-*-*-*-jisx0208.1983-0,"
|
||||||
"-*-*-*-*-*-*-*-*-*-*-*-*-jisx0212.1990-0,"
|
"-*-*-*-*-*-*-*-*-*-*-*-*-jisx0212.1990-0,"
|
||||||
"-*-*-*-*-*-*-*-*-*-*-*-*-big5-0,"
|
"-*-*-*-*-*-*-*-*-*-*-*-*-big5-0,"
|
||||||
"-*-*-*-*-*-*-*-*-*-*-*-*-jisx0201.1976-0,"
|
"-*-*-*-*-*-*-*-*-*-*-*-*-jisx0201.1976-0,"
|
||||||
"-*-unifont-*-*-*-*-*-*-*-*-*-*-iso10646-1[0x300 0x400_0x500],"
|
"-*-unifont-*-*-*-*-*-*-*-*-*-*-iso10646-1[0x300 0x400_0x500],"
|
||||||
"-*-*-*-*-*-*-*-*-*-*-*-*-*-*",
|
"-*-*-*-*-*-*-*-*-*-*-*-*-*-*",
|
||||||
&missing_charset_list_return,
|
&missing_charset_list_return,
|
||||||
&missing_charset_count_return,
|
&missing_charset_count_return,
|
||||||
&def_string_return);
|
&def_string_return);
|
||||||
mask = (GCForeground | GCBackground);
|
mask = (GCForeground | GCBackground);
|
||||||
xgcv.foreground = BlackPixel(dpy, DefaultScreen(dpy));
|
xgcv.foreground = BlackPixel(dpy, DefaultScreen(dpy));
|
||||||
xgcv.background = WhitePixel(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;
|
||||||
|
|
||||||
/***************************************************************/
|
XNextEvent(dpy, &xevent);
|
||||||
while (1) {
|
if (xevent.type == KeyPress) {
|
||||||
int filtered;
|
XKeyEvent *e = (XKeyEvent*) &xevent;
|
||||||
static XEvent xevent;
|
printf ("0x%X %d\n", e->state, e->keycode);
|
||||||
static XVaNestedList list1 = 0;
|
}
|
||||||
int r;
|
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 && !filtered) {
|
||||||
if (xevent.type == KeyPress) {
|
len = Xutf8LookupString(xim_ic, &xevent.xkey, buf, 127, &keysym, &status);
|
||||||
XKeyEvent *e = (XKeyEvent*) &xevent;
|
Xutf8DrawImageString(dpy, w, fontset, gc, x, y, buf, len);
|
||||||
printf ("0x%X %d\n", e->state, e->keycode);
|
Xutf8DrawString(dpy, w, fontset, gc, 0, 20, jp_txt, strlen(jp_txt));
|
||||||
}
|
Xutf8DrawString(dpy, w, fontset, gc, 50, 90, rtl_txt, strlen(rtl_txt));
|
||||||
filtered = XFilterEvent(&xevent, w);
|
buf[len] = 0;
|
||||||
if (xevent.type == FocusOut) XUnsetICFocus(xim_ic);
|
printf("'%s' %d\n", buf, keysym);
|
||||||
if (xevent.type == FocusIn) XSetICFocus(xim_ic);
|
buf[0] = 0;
|
||||||
|
XCloseIM(xim_im);
|
||||||
if (xevent.type == KeyPress && !filtered) {
|
}
|
||||||
len = Xutf8LookupString(xim_ic, &xevent.xkey,
|
if (filtered) {
|
||||||
buf, 127, &keysym, &status);
|
printf("Dead key\n");
|
||||||
|
}
|
||||||
Xutf8DrawImageString(dpy, w, fontset, gc,
|
}
|
||||||
x, y, buf, len);
|
XFreeFontSet(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));
|
|
||||||
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 conv_t void*
|
||||||
#define ucs4_t unsigned int
|
#define ucs4_t unsigned int
|
||||||
typedef struct {
|
typedef struct {
|
||||||
unsigned short indx;
|
unsigned short indx;
|
||||||
unsigned short used;
|
unsigned short used;
|
||||||
} Summary16;
|
} Summary16;
|
||||||
|
|
||||||
|
|
||||||
@@ -62,10 +62,10 @@ typedef struct {
|
|||||||
#include "headers/symbol_.h"
|
#include "headers/symbol_.h"
|
||||||
#include "headers/dingbats_.h"
|
#include "headers/dingbats_.h"
|
||||||
|
|
||||||
/*************** conv_gen.c ************/
|
/*************** conv_gen.c ************/
|
||||||
|
|
||||||
/*const*/
|
/*const*/
|
||||||
int ucs2fontmap(char *s, unsigned int ucs, int enc)
|
int ucs2fontmap(char *s, unsigned int ucs, int enc) {
|
||||||
{
|
|
||||||
switch(enc) {
|
switch(enc) {
|
||||||
case 0: /* iso10646-1 */
|
case 0: /* iso10646-1 */
|
||||||
s[0] = (char) ((ucs & 0xFF00) >> 8);
|
s[0] = (char) ((ucs & 0xFF00) >> 8);
|
||||||
@@ -302,8 +302,7 @@ int ucs2fontmap(char *s, unsigned int ucs, int enc)
|
|||||||
};
|
};
|
||||||
|
|
||||||
/*const*/
|
/*const*/
|
||||||
int encoding_number(const char *enc)
|
int encoding_number(const char *enc) {
|
||||||
{
|
|
||||||
if (!enc || !strncmp(enc, "iso10646-1", 10)) {
|
if (!enc || !strncmp(enc, "iso10646-1", 10)) {
|
||||||
return 0;
|
return 0;
|
||||||
} else if (!strcmp(enc, "iso8859-1")) {
|
} 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
|
* Returns -1 if the UTF-8 string is not valid
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
XConvertUtf8ToUcs(
|
XConvertUtf8ToUcs(const unsigned char *buf,
|
||||||
const unsigned char *buf,
|
int len,
|
||||||
int len,
|
unsigned int *ucs) {
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
*ucs = (unsigned int) '?'; /* bad utf-8 string */
|
if (buf[0] & 0x80) {
|
||||||
return -1;
|
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 !!!
|
* NOTE : the buffer (buf) must be at least 5 bytes long !!!
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
XConvertUcsToUtf8(
|
XConvertUcsToUtf8(unsigned int ucs,
|
||||||
unsigned int ucs,
|
char *buf) {
|
||||||
char *buf)
|
|
||||||
{
|
if (ucs < 0x000080) {
|
||||||
if (ucs < 0x000080) {
|
buf[0] = ucs;
|
||||||
buf[0] = ucs;
|
return 1;
|
||||||
return 1;
|
} else if (ucs < 0x000800) {
|
||||||
} else if (ucs < 0x000800) {
|
buf[0] = 0xC0 | (ucs >> 6);
|
||||||
buf[0] = 0xC0 | (ucs >> 6);
|
buf[1] = 0x80 | (ucs & 0x3F);
|
||||||
buf[1] = 0x80 | (ucs & 0x3F);
|
return 2;
|
||||||
return 2;
|
} else if (ucs < 0x010000) {
|
||||||
} else if (ucs < 0x010000) {
|
buf[0] = 0xE0 | (ucs >> 12);
|
||||||
buf[0] = 0xE0 | (ucs >> 12);
|
buf[1] = 0x80 | ((ucs >> 6) & 0x3F);
|
||||||
buf[1] = 0x80 | ((ucs >> 6) & 0x3F);
|
buf[2] = 0x80 | (ucs & 0x3F);
|
||||||
buf[2] = 0x80 | (ucs & 0x3F);
|
return 3;
|
||||||
return 3;
|
} else if (ucs < 0x00200000) {
|
||||||
} else if (ucs < 0x00200000) {
|
buf[0] = 0xF0 | (ucs >> 18);
|
||||||
buf[0] = 0xF0 | (ucs >> 18);
|
buf[1] = 0x80 | ((ucs >> 12) & 0x3F);
|
||||||
buf[1] = 0x80 | ((ucs >> 12) & 0x3F);
|
buf[2] = 0x80 | ((ucs >> 6) & 0x3F);
|
||||||
buf[2] = 0x80 | ((ucs >> 6) & 0x3F);
|
buf[3] = 0x80 | (ucs & 0x3F);
|
||||||
buf[3] = 0x80 | (ucs & 0x3F);
|
return 4;
|
||||||
return 4;
|
} else if (ucs < 0x01000000) {
|
||||||
} else if (ucs < 0x01000000) {
|
buf[0] = 0xF8 | (ucs >> 24);
|
||||||
buf[0] = 0xF8 | (ucs >> 24);
|
buf[1] = 0x80 | ((ucs >> 18) & 0x3F);
|
||||||
buf[1] = 0x80 | ((ucs >> 18) & 0x3F);
|
buf[2] = 0x80 | ((ucs >> 12) & 0x3F);
|
||||||
buf[2] = 0x80 | ((ucs >> 12) & 0x3F);
|
buf[3] = 0x80 | ((ucs >> 6) & 0x3F);
|
||||||
buf[3] = 0x80 | ((ucs >> 6) & 0x3F);
|
buf[4] = 0x80 | (ucs & 0x3F);
|
||||||
buf[4] = 0x80 | (ucs & 0x3F);
|
return 5;
|
||||||
return 5;
|
}
|
||||||
}
|
buf[0] = '?';
|
||||||
buf[0] = '?';
|
return -1;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -152,92 +147,88 @@ XConvertUcsToUtf8(
|
|||||||
* (returns -1 if not valid)
|
* (returns -1 if not valid)
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
XUtf8CharByteLen(
|
XUtf8CharByteLen(const unsigned char *buf,
|
||||||
const unsigned char *buf,
|
int len) {
|
||||||
int len)
|
unsigned int ucs;
|
||||||
{
|
return XConvertUtf8ToUcs(buf, len, &ucs);
|
||||||
unsigned int ucs;
|
|
||||||
return XConvertUtf8ToUcs(buf, len, &ucs);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* returns the quantity of Unicode chars in the UTF-8 string
|
* returns the quantity of Unicode chars in the UTF-8 string
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
XCountUtf8Char(
|
XCountUtf8Char(const unsigned char *buf,
|
||||||
const unsigned char *buf,
|
int len) {
|
||||||
int len)
|
|
||||||
{
|
int i = 0;
|
||||||
int i = 0;
|
int nbc = 0;
|
||||||
int nbc = 0;
|
while (i < len) {
|
||||||
while (i < len) {
|
int cl = XUtf8CharByteLen(buf + i, len - i);
|
||||||
int cl = XUtf8CharByteLen(buf + i, len - i);
|
if (cl < 1) cl = 1;
|
||||||
if (cl < 1) cl = 1;
|
nbc++;
|
||||||
nbc++;
|
i += cl;
|
||||||
i += cl;
|
}
|
||||||
}
|
return nbc;
|
||||||
return nbc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Same as XConvertUtf8ToUcs but no sanity check is done.
|
* Same as XConvertUtf8ToUcs but no sanity check is done.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
XFastConvertUtf8ToUcs(
|
XFastConvertUtf8ToUcs(const unsigned char *buf,
|
||||||
const unsigned char *buf,
|
int len,
|
||||||
int len,
|
unsigned int *ucs) {
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
*ucs = (unsigned int) '?'; /* bad utf-8 string */
|
if (buf[0] & 0x80) {
|
||||||
return -1;
|
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 */
|
#endif /* X11 only */
|
||||||
|
|||||||
+682
-717
File diff suppressed because it is too large
Load Diff
+132
-136
@@ -30,147 +30,143 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
char buffer[1000000];
|
char buffer[1000000];
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv) {
|
||||||
{
|
char buf[80];
|
||||||
char buf[80];
|
int len;
|
||||||
int len;
|
char *encode[256];
|
||||||
char *encode[256];
|
int encode_number = 0;
|
||||||
int encode_number = 0;
|
unsigned int i = 0;
|
||||||
unsigned int i = 0;
|
unsigned char *ptr;
|
||||||
unsigned char *ptr;
|
unsigned char *lst = "";
|
||||||
unsigned char *lst = "";
|
size_t nb;
|
||||||
size_t nb;
|
int nbb = 0;
|
||||||
int nbb = 0;
|
len = fread(buffer, 1, 1000000, stdin);
|
||||||
len = fread(buffer, 1, 1000000, stdin);
|
|
||||||
|
|
||||||
puts(" ");
|
puts(" ");
|
||||||
puts(" /*************** conv_gen.c ************/");
|
puts(" /*************** conv_gen.c ************/");
|
||||||
buffer[len] = '\0';
|
buffer[len] = '\0';
|
||||||
ptr = buffer;
|
ptr = buffer;
|
||||||
|
|
||||||
printf("const int ucs2fontmap"
|
printf("const int ucs2fontmap"
|
||||||
"(char *s, unsigned int ucs, int enc)\n");
|
"(char *s, unsigned int ucs, int enc)\n");
|
||||||
printf("{\n");
|
printf("{\n");
|
||||||
printf(" switch(enc) {\n");
|
printf(" switch(enc) {\n");
|
||||||
printf(" case 0:\n");
|
printf(" case 0:\n");
|
||||||
printf(" s[0] = (char) ((ucs & 0xFF00) >> 8);\n");
|
printf(" s[0] = (char) ((ucs & 0xFF00) >> 8);\n");
|
||||||
printf(" s[1] = (char) (ucs & 0xFF);\n");
|
printf(" s[1] = (char) (ucs & 0xFF);\n");
|
||||||
printf(" return 0;");
|
printf(" return 0;");
|
||||||
while (len > 0) {
|
while (len > 0) {
|
||||||
unsigned char *p = ptr;
|
unsigned char *p = ptr;
|
||||||
unsigned char *f, *t;
|
unsigned char *f, *t;
|
||||||
|
|
||||||
while (*p != ']') {
|
while (*p != ']') {
|
||||||
i++;
|
i++;
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
*(p - 1) = '\0';
|
*(p - 1) = '\0';
|
||||||
*(p - 6) = '\0';
|
*(p - 6) = '\0';
|
||||||
f = p - 5;
|
f = p - 5;
|
||||||
while (*p != '+') { i++; p++;}
|
while (*p != '+') { i++; p++;}
|
||||||
p++;
|
p++;
|
||||||
t = p;
|
t = p;
|
||||||
*(p + 4) = '\0';
|
*(p + 4) = '\0';
|
||||||
if (strcmp(lst, ptr)) {
|
if (strcmp(lst, ptr)) {
|
||||||
encode_number++;
|
encode_number++;
|
||||||
encode[encode_number] = ptr;
|
encode[encode_number] = ptr;
|
||||||
printf("\n break;");
|
printf("\n break;");
|
||||||
printf("\n case %d:\n", encode_number);
|
printf("\n case %d:\n", encode_number);
|
||||||
printf(" ");
|
printf(" ");
|
||||||
} else {
|
} else {
|
||||||
printf(" else ");
|
printf(" else ");
|
||||||
}
|
}
|
||||||
lst = ptr;
|
lst = ptr;
|
||||||
printf("if (ucs <= 0x%s) {\n", t);
|
printf("if (ucs <= 0x%s) {\n", t);
|
||||||
printf(" if (ucs >= 0x%s) {\n", f);
|
printf(" if (ucs >= 0x%s) {\n", f);
|
||||||
if (*(f - 3) == '2') {
|
if (*(f - 3) == '2') {
|
||||||
printf(" int i = (ucs - 0x%s) * 2;\n", f);
|
printf(" int i = (ucs - 0x%s) * 2;\n", f);
|
||||||
printf(" s[0] = %s_%s[i++];\n", ptr, f, f);
|
printf(" s[0] = %s_%s[i++];\n", ptr, f, f);
|
||||||
printf(" s[1] = %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",
|
printf(" if (s[0] || s[1]) return %d;\n", encode_number);
|
||||||
encode_number);
|
} else {
|
||||||
} else {
|
printf(" s[0] = 0;\n");
|
||||||
printf(" s[0] = 0;\n");
|
printf(" s[1] = %s_%s[ucs - 0x%s];\n", ptr, f, f);
|
||||||
printf(" s[1] = %s_%s[ucs - 0x%s];\n",
|
printf(" if (s[1]) return %d;\n", encode_number);
|
||||||
ptr, f, f);
|
}
|
||||||
printf(" if (s[1]) return %d;\n", encode_number);
|
printf(" }\n");
|
||||||
}
|
printf(" }");
|
||||||
printf(" }\n");
|
while (*ptr != '\n') {
|
||||||
printf(" }");
|
ptr++;
|
||||||
while (*ptr != '\n') {
|
len--;
|
||||||
ptr++;
|
}
|
||||||
len--;
|
ptr++;
|
||||||
}
|
len--;
|
||||||
ptr++;
|
}
|
||||||
len--;
|
printf("\n break;\n");
|
||||||
}
|
printf("\n default:\n");
|
||||||
printf("\n break;\n");
|
printf(" break;\n");
|
||||||
printf("\n default:\n");
|
printf(" };\n");
|
||||||
printf(" break;\n");
|
printf(" return -1;\n");
|
||||||
printf(" };\n");
|
printf("};\n\n");
|
||||||
printf(" return -1;\n");
|
|
||||||
printf("};\n\n");
|
|
||||||
|
|
||||||
printf("const int encoding_number(const char *enc)\n{\n");
|
printf("const int encoding_number(const char *enc)\n{\n");
|
||||||
printf(" if (!enc || !strcmp(enc, \"iso10646-1\")) {\n");
|
printf(" if (!enc || !strcmp(enc, \"iso10646-1\")) {\n");
|
||||||
printf(" return 0;\n");
|
printf(" return 0;\n");
|
||||||
i = 1;
|
i = 1;
|
||||||
while (i <= encode_number) {
|
while (i <= encode_number) {
|
||||||
int l;
|
int l;
|
||||||
char *ptr;
|
char *ptr;
|
||||||
l = strlen(encode[i]) - 3;
|
l = strlen(encode[i]) - 3;
|
||||||
ptr = encode[i] + l;
|
ptr = encode[i] + l;
|
||||||
*(ptr) = '\0';
|
*(ptr) = '\0';
|
||||||
ptr--;
|
ptr--;
|
||||||
while (ptr != encode[i]) {
|
while (ptr != encode[i]) {
|
||||||
if (*ptr == '_') {
|
if (*ptr == '_') {
|
||||||
*ptr = '-';
|
*ptr = '-';
|
||||||
ptr--;
|
ptr--;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ptr--;
|
ptr--;
|
||||||
}
|
}
|
||||||
while (ptr != encode[i]) {
|
while (ptr != encode[i]) {
|
||||||
if (*ptr == '_') {
|
if (*ptr == '_') {
|
||||||
*ptr = '.';
|
*ptr = '.';
|
||||||
}
|
}
|
||||||
ptr--;
|
ptr--;
|
||||||
}
|
}
|
||||||
printf(" } else if (!strcmp(enc, \"%s\")", encode[i] +11);
|
printf(" } else if (!strcmp(enc, \"%s\")", encode[i] +11);
|
||||||
|
|
||||||
if (!strcmp(encode[i] + 11, "big5-0")) {
|
if (!strcmp(encode[i] + 11, "big5-0")) {
|
||||||
printf(" || !strcmp(enc, \"big5.eten-0\")");
|
printf(" || !strcmp(enc, \"big5.eten-0\")");
|
||||||
} else if (!strcmp(encode[i] + 11, "dingbats")) {
|
} else if (!strcmp(encode[i] + 11, "dingbats")) {
|
||||||
printf(" || !strcmp(enc, \"zapfdingbats\")");
|
printf(" || !strcmp(enc, \"zapfdingbats\")");
|
||||||
printf(" || !strcmp(enc, \"zapf dingbats\")");
|
printf(" || !strcmp(enc, \"zapf dingbats\")");
|
||||||
printf(" || !strcmp(enc, \"itc zapf dingbats\")");
|
printf(" || !strcmp(enc, \"itc zapf dingbats\")");
|
||||||
} else if (!strcmp(encode[i] + 11, "jisx0208.1983-0")) {
|
} else if (!strcmp(encode[i] + 11, "jisx0208.1983-0")) {
|
||||||
printf(" || !strcmp(enc, \"jisx0208.1990-0\")");
|
printf(" || !strcmp(enc, \"jisx0208.1990-0\")");
|
||||||
}
|
}
|
||||||
|
|
||||||
printf(") {\n");
|
printf(") {\n");
|
||||||
printf(" return %d;\n", i);
|
printf(" return %d;\n", i);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
printf(" };\n");
|
printf(" };\n");
|
||||||
printf(" return -1;\n");
|
printf(" return -1;\n");
|
||||||
printf("};\n\n");
|
printf("};\n\n");
|
||||||
|
|
||||||
|
printf("/*\n");
|
||||||
printf("/*\n");
|
printf("const char *encoding_name(int num)\n{\n");
|
||||||
printf("const char *encoding_name(int num)\n{\n");
|
printf(" switch (num) {\n");
|
||||||
printf(" switch (num) {\n");
|
i = 1;
|
||||||
i = 1;
|
while (i <= encode_number) {
|
||||||
while (i <= encode_number) {
|
printf(" case %d:\n", i);
|
||||||
printf(" case %d:\n", i);
|
printf(" return \"%s\";\n", encode[i] + 11);
|
||||||
printf(" return \"%s\";\n", encode[i] + 11);
|
i++;
|
||||||
i++;
|
}
|
||||||
}
|
printf(" };\n");
|
||||||
printf(" };\n");
|
printf(" return \"iso10646-1\";\n");
|
||||||
printf(" return \"iso10646-1\";\n");
|
printf("};\n\n");
|
||||||
printf("};\n\n");
|
printf("*/\n");
|
||||||
printf("*/\n");
|
return 0;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
+128
-132
@@ -33,149 +33,145 @@
|
|||||||
|
|
||||||
char buffer[1000000];
|
char buffer[1000000];
|
||||||
|
|
||||||
int JIS0208(unsigned char * ptr)
|
int JIS0208(unsigned char * ptr) {
|
||||||
{
|
int i = 0;
|
||||||
int i = 0;
|
unsigned int fmap;
|
||||||
unsigned int fmap;
|
unsigned int ucs;
|
||||||
unsigned int ucs;
|
while(*ptr != '\t') { ptr++; i++; }
|
||||||
while(*ptr != '\t') { ptr++; i++; }
|
ptr++; i++; *(ptr+6) = '\0';
|
||||||
ptr++; i++; *(ptr+6) = '\0';
|
fmap = (unsigned int)strtoul(ptr, NULL, 16);
|
||||||
fmap = (unsigned int)strtoul(ptr, NULL, 16);
|
while(*ptr != '\0') { ptr++; i++; }
|
||||||
while(*ptr != '\0') { ptr++; i++; }
|
i++; ptr++; *(ptr+6) = '\0';
|
||||||
i++; ptr++; *(ptr+6) = '\0';
|
ucs = (unsigned int)strtoul(ptr, NULL, 16);
|
||||||
ucs = (unsigned int)strtoul(ptr, NULL, 16);
|
if (ucs)
|
||||||
if (ucs) printf("/* U+%04X */ 0x%02X, 0x%02X,\n", ucs,
|
printf("/* U+%04X */ 0x%02X, 0x%02X,\n", ucs,
|
||||||
(fmap & 0xFF00) >> 8, fmap & 0xFF);
|
(fmap & 0xFF00) >> 8, fmap & 0xFF);
|
||||||
while(*ptr != '\0') { ptr++; i++; }
|
while(*ptr != '\0') { ptr++; i++; }
|
||||||
i++; ptr++;
|
i++; ptr++;
|
||||||
while(*ptr != '\n') { ptr++; i++; }
|
while(*ptr != '\n') { ptr++; i++; }
|
||||||
i++;
|
i++;
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
int JIS0201(unsigned char * ptr)
|
int JIS0201(unsigned char * ptr) {
|
||||||
{
|
int i = 0;
|
||||||
int i = 0;
|
unsigned int fmap;
|
||||||
unsigned int fmap;
|
unsigned int ucs;
|
||||||
unsigned int ucs;
|
*(ptr+4) = '\0';
|
||||||
*(ptr+4) = '\0';
|
fmap = (unsigned int)strtoul(ptr, NULL, 16);
|
||||||
fmap = (unsigned int)strtoul(ptr, NULL, 16);
|
while(*ptr != '\0') { ptr++; i++; }
|
||||||
while(*ptr != '\0') { ptr++; i++; }
|
i++; ptr++; *(ptr+6) = '\0';
|
||||||
i++; ptr++; *(ptr+6) = '\0';
|
ucs = (unsigned int)strtoul(ptr, NULL, 16);
|
||||||
ucs = (unsigned int)strtoul(ptr, NULL, 16);
|
if (*(ptr + 1) != 'x') {
|
||||||
if (*(ptr + 1) != 'x') {
|
printf("/* EOF */\n");
|
||||||
printf("/* EOF */\n");
|
abort();
|
||||||
abort();
|
}
|
||||||
}
|
if (ucs) printf("/* U+%04X */ 0x%02X,\n", ucs, (unsigned char)fmap);
|
||||||
if (ucs) printf("/* U+%04X */ 0x%02X,\n", ucs, (unsigned char)fmap);
|
while(*ptr != '\0') { ptr++; i++; }
|
||||||
while(*ptr != '\0') { ptr++; i++; }
|
i++; ptr++;
|
||||||
i++; ptr++;
|
while(*ptr != '\n') { ptr++; i++; }
|
||||||
while(*ptr != '\n') { ptr++; i++; }
|
i++;
|
||||||
i++;
|
return i;
|
||||||
return i;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ADOBE(unsigned char * ptr)
|
int ADOBE(unsigned char * ptr) {
|
||||||
{
|
int i = 0;
|
||||||
int i = 0;
|
unsigned int fmap;
|
||||||
unsigned int fmap;
|
unsigned int ucs;
|
||||||
unsigned int ucs;
|
*(ptr+4) = '\0';
|
||||||
*(ptr+4) = '\0';
|
ucs = (unsigned int)strtoul(ptr, NULL, 16);
|
||||||
ucs = (unsigned int)strtoul(ptr, NULL, 16);
|
while(*ptr != '\0') { ptr++; i++; }
|
||||||
while(*ptr != '\0') { ptr++; i++; }
|
i++; ptr++; *(ptr+2) = '\0';
|
||||||
i++; ptr++; *(ptr+2) = '\0';
|
fmap = (unsigned int)strtoul(ptr, NULL, 16);
|
||||||
fmap = (unsigned int)strtoul(ptr, NULL, 16);
|
if (fmap < 1) {
|
||||||
if (fmap < 1) {
|
printf("/* EOF */\n");
|
||||||
printf("/* EOF */\n");
|
abort();
|
||||||
abort();
|
}
|
||||||
}
|
if (ucs) printf("/* U+%04X */ 0x%02X,\n", ucs, (unsigned char)fmap);
|
||||||
if (ucs) printf("/* U+%04X */ 0x%02X,\n", ucs, (unsigned char)fmap);
|
while(*ptr != '\0') { ptr++; i++; }
|
||||||
while(*ptr != '\0') { ptr++; i++; }
|
i++; ptr++;
|
||||||
i++; ptr++;
|
while(*ptr != '\n') { ptr++; i++; }
|
||||||
while(*ptr != '\n') { ptr++; i++; }
|
i++;
|
||||||
i++;
|
return i;
|
||||||
return i;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int JIS0212(unsigned char * ptr)
|
int JIS0212(unsigned char * ptr) {
|
||||||
{
|
int i = 0;
|
||||||
int i = 0;
|
unsigned int fmap;
|
||||||
unsigned int fmap;
|
unsigned int ucs;
|
||||||
unsigned int ucs;
|
*(ptr+6) = '\0';
|
||||||
*(ptr+6) = '\0';
|
fmap = (unsigned int)strtoul(ptr, NULL, 16);
|
||||||
fmap = (unsigned int)strtoul(ptr, NULL, 16);
|
ptr += 7;
|
||||||
ptr += 7;
|
i += 7;
|
||||||
i += 7;
|
while(*ptr == ' ') { ptr++; i++; }
|
||||||
while(*ptr == ' ') { ptr++; i++; }
|
//i++; ptr++;
|
||||||
//i++; ptr++;
|
*(ptr+6) = '\0';
|
||||||
*(ptr+6) = '\0';
|
ucs = (unsigned int)strtoul(ptr, NULL, 16);
|
||||||
ucs = (unsigned int)strtoul(ptr, NULL, 16);
|
if (*(ptr + 1) != 'x') {
|
||||||
if (*(ptr + 1) != 'x') {
|
printf("/* EOF */\n");
|
||||||
printf("/* EOF */\n");
|
abort();
|
||||||
abort();
|
}
|
||||||
}
|
if (ucs)
|
||||||
if (ucs) printf("/* U+%04X */ 0x%02X, 0x%02X,\n", ucs,
|
printf("/* U+%04X */ 0x%02X, 0x%02X,\n", ucs,
|
||||||
(fmap & 0xFF00) >> 8, fmap & 0xFF);
|
(fmap & 0xFF00) >> 8, fmap & 0xFF);
|
||||||
while(*ptr != '\0') { ptr++; i++; }
|
while(*ptr != '\0') { ptr++; i++; }
|
||||||
i++; ptr++;
|
i++; ptr++;
|
||||||
while(*ptr != '\n') { ptr++; i++; }
|
while(*ptr != '\n') { ptr++; i++; }
|
||||||
i++;
|
i++;
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv) {
|
||||||
{
|
char buf[80];
|
||||||
char buf[80];
|
int len;
|
||||||
int len;
|
int i;
|
||||||
int i;
|
unsigned char *ptr;
|
||||||
unsigned char *ptr;
|
size_t nb;
|
||||||
size_t nb;
|
len = fread(buffer, 1, 1000000, stdin);
|
||||||
len = fread(buffer, 1, 1000000, stdin);
|
|
||||||
|
|
||||||
buffer[len] = '\0';
|
buffer[len] = '\0';
|
||||||
ptr = (unsigned char *)buffer;
|
ptr = (unsigned char *)buffer;
|
||||||
while (*ptr !='\n') {ptr++; len--;};
|
while (*ptr !='\n') {ptr++; len--;};
|
||||||
ptr++; len--;
|
ptr++; len--;
|
||||||
while (*ptr == '#') {
|
while (*ptr == '#') {
|
||||||
while (*ptr !='\n') {
|
while (*ptr !='\n') {
|
||||||
ptr++;
|
ptr++;
|
||||||
len--;
|
len--;
|
||||||
}
|
}
|
||||||
ptr++;
|
ptr++;
|
||||||
len--;
|
len--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while (len > 0) {
|
||||||
while (len > 0) {
|
nb = 0;
|
||||||
nb = 0;
|
if (!strcmp("jisx0208.1983-0", argv[1])) {
|
||||||
if (!strcmp("jisx0208.1983-0", argv[1])) {
|
nb = JIS0208(ptr);
|
||||||
nb = JIS0208(ptr);
|
} else if (!strcmp("jisx0201.1976-0", argv[1])) {
|
||||||
} else if (!strcmp("jisx0201.1976-0", argv[1])) {
|
nb = JIS0201(ptr);
|
||||||
nb = JIS0201(ptr);
|
} else if (!strcmp("jisx0212.1990-0", argv[1])) {
|
||||||
} else if (!strcmp("jisx0212.1990-0", argv[1])) {
|
nb = JIS0212(ptr);
|
||||||
nb = JIS0212(ptr);
|
} else if (!strcmp("gb2312.1980-0", argv[1])) {
|
||||||
} else if (!strcmp("gb2312.1980-0", argv[1])) {
|
nb = JIS0212(ptr);
|
||||||
nb = JIS0212(ptr);
|
} else if (!strcmp("ksc5601.1987-0", argv[1])) {
|
||||||
} else if (!strcmp("ksc5601.1987-0", argv[1])) {
|
nb = JIS0212(ptr);
|
||||||
nb = JIS0212(ptr);
|
} else if (!strcmp("big5-0", argv[1])) {
|
||||||
} else if (!strcmp("big5-0", argv[1])) {
|
nb = JIS0212(ptr);
|
||||||
nb = JIS0212(ptr);
|
} else if (!strncmp("iso8859", argv[1], 7)) {
|
||||||
} else if (!strncmp("iso8859", argv[1], 7)) {
|
nb = JIS0201(ptr);
|
||||||
nb = JIS0201(ptr);
|
} else if (!strcmp("koi8-1", argv[1])) {
|
||||||
} else if (!strcmp("koi8-1", argv[1])) {
|
nb = JIS0201(ptr);
|
||||||
nb = JIS0201(ptr);
|
} else if (!strcmp("dingbats", argv[1]) ||
|
||||||
} else if (!strcmp("dingbats", argv[1]) ||
|
!strcmp("symbol", argv[1]))
|
||||||
!strcmp("symbol", argv[1]))
|
{
|
||||||
{
|
nb = ADOBE(ptr);
|
||||||
nb = ADOBE(ptr);
|
} else {
|
||||||
} else {
|
len = 0;
|
||||||
len = 0;
|
}
|
||||||
}
|
ptr += nb;
|
||||||
ptr += nb;
|
len = len - nb;
|
||||||
len = len - nb;
|
}
|
||||||
}
|
return 0;
|
||||||
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 <wchar.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
char buffer[1000000];
|
char buffer[1000000];
|
||||||
@@ -5,85 +30,83 @@ char buffer[1000000];
|
|||||||
/*** you can try to modifie this value to have better performences **/
|
/*** you can try to modifie this value to have better performences **/
|
||||||
#define MAX_DELTA 0x80
|
#define MAX_DELTA 0x80
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv) {
|
||||||
{
|
char buf[80];
|
||||||
char buf[80];
|
int len;
|
||||||
int len;
|
unsigned int i = 0;
|
||||||
unsigned int i = 0;
|
unsigned char *ptr;
|
||||||
unsigned char *ptr;
|
size_t nb;
|
||||||
size_t nb;
|
int nbb = 0;
|
||||||
int nbb = 0;
|
len = fread(buffer, 1, 1000000, stdin);
|
||||||
len = fread(buffer, 1, 1000000, stdin);
|
|
||||||
|
|
||||||
buffer[len] = '\0';
|
buffer[len] = '\0';
|
||||||
ptr = (unsigned char *)buffer;
|
ptr = (unsigned char *)buffer;
|
||||||
while (*ptr != '\n') ptr++;
|
while (*ptr != '\n') ptr++;
|
||||||
ptr++;
|
ptr++;
|
||||||
while (*ptr != '\n') {
|
while (*ptr != '\n') {
|
||||||
if (*ptr == ',') nbb++;
|
if (*ptr == ',') nbb++;
|
||||||
ptr++;
|
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;
|
if (strcmp(argv[1], "spacing")) {
|
||||||
printf("/* %s */\n", argv[1]);
|
printf("\nstatic const char unicode_to_%s_%db_%04X[] = {\n",
|
||||||
while (len > 0) {
|
argv[1], nbb, ucs);
|
||||||
unsigned int ucs = 0;
|
fprintf(stderr, "unicode_to_%s_%db_%04X[]; ",
|
||||||
char *p = ptr;
|
argv[1], nbb, ucs);
|
||||||
char pp[20];
|
} else {
|
||||||
nb = 0;
|
printf("\nstatic const unsigned short"
|
||||||
pp[0] = '\0';
|
" ucs_table_%04X[]"
|
||||||
while (*p != 'U') p++;
|
" = {\n", ucs);
|
||||||
strncat(pp, p, 6);
|
fprintf(stderr, "ucs_table_%04X[]; ", ucs);
|
||||||
*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--;
|
|
||||||
}
|
}
|
||||||
printf("};\n");
|
} else {
|
||||||
fprintf(stderr, "\t/* end: U+%04X */\n", i);
|
while (i < ucs - 1) {
|
||||||
return 0;
|
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];
|
char uni[0x10000];
|
||||||
#include "../utf8Utils.c"
|
#include "../utf8Utils.c"
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv) {
|
||||||
{
|
|
||||||
|
|
||||||
iconv_t cd;
|
iconv_t cd;
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
cd = iconv_open("EUC-TW", "UTF16");
|
cd = iconv_open("EUC-TW", "UTF16");
|
||||||
for(i = 0; i < 0x10000; i++) uni[i] = 0;
|
for(i = 0; i < 0x10000; i++) uni[i] = 0;
|
||||||
for(i = 0x00000000; i < 0xFFFFFFFF; i++) {
|
for(i = 0x00000000; i < 0xFFFFFFFF; i++) {
|
||||||
char buf[4], ob[6];
|
char buf[4], ob[6];
|
||||||
char *b = buf;
|
char *b = buf;
|
||||||
int ucs = -1;
|
int ucs = -1;
|
||||||
int l1 = 4, l2 = 6;
|
int l1 = 4, l2 = 6;
|
||||||
char *o = ob ;
|
char *o = ob ;
|
||||||
buf[0] = i & 0xff;
|
buf[0] = i & 0xff;
|
||||||
buf[1] = (i >> 8) & 0xFF;
|
buf[1] = (i >> 8) & 0xFF;
|
||||||
buf[2] = (i >> 16) & 0xFF;
|
buf[2] = (i >> 16) & 0xFF;
|
||||||
buf[3] = (i >> 24) & 0xFF;
|
buf[3] = (i >> 24) & 0xFF;
|
||||||
iconv(cd, NULL, NULL, NULL, NULL);
|
iconv(cd, NULL, NULL, NULL, NULL);
|
||||||
iconv(cd, &b, &l1, &o, &l2);
|
iconv(cd, &b, &l1, &o, &l2);
|
||||||
if (l2 != 6) {
|
if (l2 != 6) {
|
||||||
ucs = (unsigned)ob[0];
|
ucs = (unsigned)ob[0];
|
||||||
ucs += (unsigned) (ob[1] << 8);
|
ucs += (unsigned) (ob[1] << 8);
|
||||||
//XConvertUtf8ToUcs((unsigned char*)ob, 6 - l2, &ucs);
|
//XConvertUtf8ToUcs((unsigned char*)ob, 6 - l2, &ucs);
|
||||||
printf ("%x --> %X\n", i, ucs & 0xFFFF);
|
printf ("%x --> %X\n", i, ucs & 0xFFFF);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
iconv_close(cd);
|
||||||
iconv_close(cd);
|
return 0;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user