
|
Fwd: Squeak on UTF-8 system
Begin forwarded message:
> From: Martin Kuball < martinkuball@...>
> Date: March 20, 2006 10:38:03 AM PST
> To: The general-purpose Squeak developers list <squeak-
> dev@...>
> Subject: Re: Squeak on UTF-8 system
> Reply-To: The general-purpose Squeak developers list <squeak-
> dev@...>
>
> Am Friday, 17. March 2006 19:51 schrieb Martin Kuball:
>> Am Thursday, 16. March 2006 21:10 schrieb Petr Fischer:
>>>> About 1 and a half year ago I submitted a patch for the unix
>>>> keyboard input handler of the VM to make it utf8 ready.
>>>> Unfortunately it never got included. Maybe it's time to try
>>>> again.
>>>>
>>>> Martin
>>>
>>> Share it please. Thanks! pf
>>
>> I don't have much time this weekend. But I will try to dig up the
>> stuff and post it here.
>
> I'm not sure if the patches are still needed. Some previous mails
> suggested that it's possible to make it work by specifing the right
> parameters on the comandline. Well, it does not work for me. So find
> attached to this mail the patches I made over a year ago.
> Unfortunately I wasn't able to test them with a recent VM. I tried
> with the svn version but it failed to compile because of some missing
> methods (like fetchLong32ofObject).
>
> Martin [Makefile.in.patch] Index: Makefile.in
===================================================================
RCS file: /cvsroot/squeak/squeak/platforms/unix/config/Makefile.in,v
retrieving revision 1.9
diff -c -r1.9 Makefile.in
*** Makefile.in 2 Apr 2004 00:52:12 -0000 1.9
--- Makefile.in 8 Oct 2004 09:54:42 -0000
***************
*** 52,58 ****
# VM
$(squeak) : config.sh $(SQLIBS) version.o
! $(LINK) $(squeak) $(SQLIBS) version.o $(LIBS) [plibs] vm/vm.a
@echo
@size $(squeak)
@echo
--- 52,58 ----
# VM
$(squeak) : config.sh $(SQLIBS) version.o
! $(LINK) $(squeak) $(SQLIBS) version.o $(LIBS) [plibs]
@echo
@size $(squeak)
@echo
[sqUnixMain.c.patch] Index: sqUnixMain.c
===================================================================
RCS file: /cvsroot/squeak/squeak/platforms/unix/vm/sqUnixMain.c,v
retrieving revision 1.15
diff -c -r1.15 sqUnixMain.c
*** sqUnixMain.c 3 Apr 2004 10:24:11 -0000 1.15
--- sqUnixMain.c 8 Oct 2004 10:02:46 -0000
***************
*** 929,934 ****
--- 929,935 ----
if ((ev= getenv("SQUEAK_ENCODING"))) setEncoding(&sqTextEncoding, ev);
if ((ev= getenv("SQUEAK_PATHENC"))) setEncoding(&uxPathEncoding, ev);
if ((ev= getenv("SQUEAK_TEXTENC"))) setEncoding(&uxTextEncoding, ev);
+ if ((ev= getenv("SQUEAK_EVENTENC"))) setEncoding(&uxXWinEncoding, ev);
if ((ev= getenv("SQUEAK_VM"))) requireModulesNamed(ev);
}
***************
*** 1006,1026 ****
else if (!strcmp(argv[0], "-plugins")) { squeakPlugins= strdup(argv[1]); return 2; }
else if (!strcmp(argv[0], "-encoding")) { setEncoding(&sqTextEncoding, argv[1]); return 2; }
else if (!strcmp(argv[0], "-pathenc")) { setEncoding(&uxPathEncoding, argv[1]); return 2; }
else if (!strcmp(argv[0], "-textenc"))
! {
! char *buf= (char *)malloc(strlen(argv[1]) + 1);
! int len, i;
! strcpy(buf, argv[1]);
! len= strlen(buf);
! for (i= 0; i < len; ++i)
! buf[i]= toupper(buf[i]);
! if ((!strcmp(buf, "UTF8")) || (!strcmp(buf, "UTF-8")))
! textEncodingUTF8= 1;
! else
! setEncoding(&uxTextEncoding, buf);
! free(buf);
! return 2;
! }
}
return 0; /* option not recognised */
}
--- 1007,1032 ----
else if (!strcmp(argv[0], "-plugins")) { squeakPlugins= strdup(argv[1]); return 2; }
else if (!strcmp(argv[0], "-encoding")) { setEncoding(&sqTextEncoding, argv[1]); return 2; }
else if (!strcmp(argv[0], "-pathenc")) { setEncoding(&uxPathEncoding, argv[1]); return 2; }
+ else if (!strcmp(argv[0], "-eventenc"))
+ {
+ setEncoding(&uxXWinEncoding, argv[1]);
+ return 2;
+ }
else if (!strcmp(argv[0], "-textenc"))
! {
! char *buf= (char *)malloc(strlen(argv[1]) + 1);
! int len, i;
! strcpy(buf, argv[1]);
! len= strlen(buf);
! for (i= 0; i < len; ++i)
! buf[i]= toupper(buf[i]);
! if ((!strcmp(buf, "UTF8")) || (!strcmp(buf, "UTF-8")))
! textEncodingUTF8= 1;
! else
! setEncoding(&uxTextEncoding, buf);
! free(buf);
! return 2;
! }
}
return 0; /* option not recognised */
}
***************
*** 1036,1041 ****
--- 1042,1048 ----
printf(" -mmap <size>[mk] limit dynamic heap size (default: %dm)\n", DefaultMmapSize);
printf(" -noevents disable event-driven input support\n");
printf(" -notimer disable interval timer for low-res clock \n");
+ printf(" -eventenc <enc> set encoding for key events (default: ISO-8859-1, or UTF-8 if you have an utf-8 locale\n");
printf(" -pathenc <enc> set encoding for pathnames (default: UTF-8)\n");
printf(" -plugins <path> specify alternative plugin location (see manpage)\n");
printf(" -textenc <enc> set encoding for external text (default: UTF-8)\n");
[sqUnixX11.c.patch] Index: sqUnixX11.c
===================================================================
RCS file: /cvsroot/squeak/squeak/platforms/unix/vm-display-X11/sqUnixX11.c,v
retrieving revision 1.15
diff -c -r1.15 sqUnixX11.c
*** sqUnixX11.c 3 Apr 2004 21:48:57 -0000 1.15
--- sqUnixX11.c 8 Oct 2004 10:03:30 -0000
***************
*** 1024,1044 ****
}
! int recode(int charCode)
{
! if (charCode >= 128)
! {
! unsigned char buf[32];
! unsigned char out[32];
! buf[0]= charCode;
! if (convertChars((char *)buf, 1, uxXWinEncoding,
! (char *)out, sizeof(out),
! sqTextEncoding, 0, 1))
! charCode= out[0];
! # if defined(DEBUG_EVENTS)
! fprintf(stderr, " 8-bit: %d=%02x [%c->%c]\n", charCode, charCode,
! (char *)uxXWinEncoding, (char *)sqTextEncoding);
! # endif
}
return charCode;
}
--- 1024,1044 ----
}
! int recode(char *buffer, int count)
{
! unsigned char out[32];
! int charCode= -1;
! int resLength= 0;
! resLength= convertChars(buffer, count, uxXWinEncoding,
! (char *)out, sizeof(out),
! sqTextEncoding, 0, 1);
! if (resLength > 0)
! {
! charCode= out[0]; /* only single-byte chars for now*/
! # if defined(DEBUG_EVENTS)
! fprintf(stderr, " 8-bit: %d=%02x [%s->%s]\n", charCode, charCode,
! (char *)uxXWinEncoding, (char *)sqTextEncoding);
! # endif
}
return charCode;
}
***************
*** 1050,1071 ****
static XIM im= 0;
static XIC ic= 0;
static int lastKey= -1;
if (!initialised)
{
initialised= 1;
if (!setlocale(LC_CTYPE, ""))
! {
! fprintf(stderr, "setlocale() failed (check values of LC_CTYPE, LANG and LC_ALL)\n");
! goto revertInput;
! }
if (!(im= XOpenIM(stDisplay, 0, 0, 0)))
! {
! fprintf(stderr, "XOpenIM() failed\n");
! goto revertInput;
! }
else
! {
if (!(ic= XCreateIC(im, XNInputStyle, XIMPreeditNothing | XIMStatusNothing,
XNClientWindow, stWindow, 0)))
{
--- 1050,1080 ----
static XIM im= 0;
static XIC ic= 0;
static int lastKey= -1;
+ const char *xLocale= 0;
if (!initialised)
{
initialised= 1;
if (!setlocale(LC_CTYPE, ""))
! {
! fprintf(stderr, "setlocale() failed (check values of LC_CTYPE, LANG and LC_ALL)\n");
! goto revertInput;
! }
if (!(im= XOpenIM(stDisplay, 0, 0, 0)))
! {
! fprintf(stderr, "XOpenIM() failed\n");
! goto revertInput;
! }
else
! {
! xLocale = XLocaleOfIM(im);
! if (strstr(xLocale, "UTF-8") || strstr(xLocale, "UTF8"))
! {
! setEncoding(&uxXWinEncoding, "UTF-8");
! textEncodingUTF8 = 1;
! /* TODO set other encodings to utf8, too? */
! }
!
if (!(ic= XCreateIC(im, XNInputStyle, XIMPreeditNothing | XIMStatusNothing,
XNClientWindow, stWindow, 0)))
{
***************
*** 1081,1087 ****
mask |= xwa.your_event_mask;
XSelectInput(stDisplay, stWindow, mask);
}
! }
}
if (KeyPress != xevt->type)
--- 1090,1096 ----
mask |= xwa.your_event_mask;
XSelectInput(stDisplay, stWindow, mask);
}
! }
}
if (KeyPress != xevt->type)
***************
*** 1096,1113 ****
#endif
{
! unsigned char string[128]; /* way too much */
KeySym symbolic;
Status status;
int count= XmbLookupString(ic, (XKeyPressedEvent *)xevt,
string, sizeof(string), &symbolic, &status);
switch (status)
{
case XLookupNone: /* still composing */
! # if defined(DEBUG_CONV)
! fprintf(stderr, "x2sqKey XLookupNone\n");
! # endif
! return -1;
case XLookupChars:
# if defined(DEBUG_CONV)
--- 1105,1127 ----
#endif
{
! unsigned char string[8];
KeySym symbolic;
Status status;
int count= XmbLookupString(ic, (XKeyPressedEvent *)xevt,
string, sizeof(string), &symbolic, &status);
switch (status)
{
+ case XBufferOverflow:
+ # if defined(DEBUG_CONV)
+ fprintf(stderr, "buffer overflow in XmbLookupString: %i", count);
+ # endif
+ return -1;
case XLookupNone: /* still composing */
! # if defined(DEBUG_CONV)
! fprintf(stderr, "x2sqKey XLookupNone\n");
! # endif
! return -1;
case XLookupChars:
# if defined(DEBUG_CONV)
***************
*** 1117,1123 ****
# if defined(DEBUG_CONV)
fprintf(stderr, "x2sqKey XLookupBoth count %d\n", count);
# endif
! lastKey= (count ? recode(string[0]) : -1);
# if defined(DEBUG_CONV)
fprintf(stderr, "x2sqKey == %d\n", lastKey);
# endif
--- 1131,1137 ----
# if defined(DEBUG_CONV)
fprintf(stderr, "x2sqKey XLookupBoth count %d\n", count);
# endif
! lastKey= (count ? recode(string, count) : -1);
# if defined(DEBUG_CONV)
fprintf(stderr, "x2sqKey == %d\n", lastKey);
# endif
***************
*** 1171,1177 ****
modifierState= charCode >> 8;
charCode &= 0xff;
}
! return recode(charCode);
}
--- 1185,1191 ----
modifierState= charCode >> 8;
charCode &= 0xff;
}
! return recode((char *)buf, nConv);
}
>
--
========================================================================
===
John M. McIntosh < johnmci@...> 1-800-477-2659
Corporate Smalltalk Consulting Ltd. http://www.smalltalkconsulting.com========================================================================
===
|