Artifacts Associated With Ticket 217899ffffffffff
Ticket change [98c3fef0cc] (rid 110668) by nobody on 2000-10-26 00:45:36:
- assignee initialized to: "nobody"
- cmimetype initialized to: "text/plain"
- comment initialized to:
OriginalBugID: 2521 Bug Version: 8.2b2 SubmitDate: '1999-08-11' LastModified: '2000-04-09' Severity: SER Status: Closed Submitter: techsupp ChangedBy: hobbs RelatedBugIDs: 2522 3345 4236 OS: Linux OSVersion: Debian 2.1 Machine: Other FixedDate: '2000-10-25' ClosedDate: '2000-04-09' Name: Victor Wagner Comments: It would be nice to be able to change locale inside Tcl script (for example via traces on LC_ environment variables). It would save much trouble with date formatting and parsing. ReproducibleScript: Any wish script with locale ru_RU.KOI8-R ObservedBehavior: Tk scripts don't accept Cyrillic keyboard input. Investigation shows that when current encoding is determined from LANG environment variable and this variable has <language>_<country>.<encoding> format, goto resetPath statement is performed and setlocale call is skipped. Moreover, even if this code is executed, Tcl sets locale temporarily to user settings and then resets it (all categories) back, when resetting of LC_NUMERIC only is enough for correct parsing of numbers (and this is performed two lines down the code). clock format prints date in English when explicitely told to use locale-specific format (-format "%c"). When Tcl is patched to support locale, clock format incorrectly assumes that strftime returns string in ISO8859-1 encoding and doesn't attempt to convert it from current system default encoding. DesiredBehavior: All locale categories, except LC_NUMERIC should be set to user locale. setlocale call should be performed to initilize X input method correctly, regardless of locale value. date/time values should be formatted according to user preferences. If app author wished, he always can set format to recognizable by clock scan explicitely. May be even default format should be one of those, instead of "%c", but there should be way to obtain locale-specific date/time format via clock format. Patch: diff -c -r tcl8.2b2/generic/tclClock.c tcl8.2b2-patched/generic/tclClock.c *** tcl8.2b2/generic/tclClock.cFri Apr 16 04:46:43 1999 --- tcl8.2b2-patched/generic/tclClock.cWed Aug 11 17:23:22 1999 *************** *** 228,234 **** char *format;/* Format string */ { struct tm *timeDataPtr; ! Tcl_DString buffer; int bufSize; char *p; Tcl_Obj *resultPtr; --- 228,234 ---- char *format;/* Format string */ { struct tm *timeDataPtr; ! Tcl_DString buffer,unicode_buffer; int bufSize; char *p; Tcl_Obj *resultPtr; *************** *** 315,322 **** "\"", (char *) NULL); return TCL_ERROR; } ! ! Tcl_SetStringObj(resultPtr, buffer.string, -1); Tcl_DStringFree(&buffer); return TCL_OK; } --- 315,324 ---- "\"", (char *) NULL); return TCL_ERROR; } ! Tcl_DStringInit(&unicode_buffer); ! Tcl_ExternalToUtfDString(NULL,buffer.string,-1,&unicode_buffer); ! Tcl_SetStringObj(resultPtr, unicode_buffer.string, -1 ); ! Tcl_DStringFree(&unicode_buffer); Tcl_DStringFree(&buffer); return TCL_OK; } diff -c -r tcl8.2b2/unix/tclUnixInit.c tcl8.2b2-patched/unix/tclUnixInit.c *** tcl8.2b2/unix/tclUnixInit.cFri Jul 23 01:50:56 1999 --- tcl8.2b2-patched/unix/tclUnixInit.cWed Aug 11 17:00:57 1999 *************** *** 432,437 **** --- 432,438 ---- Tcl_SetSystemEncoding(NULL, encoding); + resetPath: /* * Initialize the C library's locale subsystem. This is required * for input methods to work properly on X11. Note that we need to *************** *** 443,449 **** Tcl_DStringInit(&ds); Tcl_DStringAppend(&ds, setlocale(LC_ALL, NULL), -1); setlocale(LC_ALL, ""); - setlocale(LC_ALL, Tcl_DStringValue(&ds)); Tcl_DStringFree(&ds); [ED NOTE: SHOULD REMOVE ALL DString STUFF, IF ANY] /* --- 444,449 ---- *************** *** 478,484 **** * encoding. */ - resetPath: pathPtr = TclGetLibraryPath(); if (pathPtr != NULL) { int objc; --- 478,483 ---- PatchFiles: generic/tclClock.c unix/tkUnixInit.c With this patch, the locale would be set to the user defined environment, which may cause problems in the Tcl C library. The intent of the above setlocale NULL->""->original, is that we expect to get the current runtime setting (should be C for the C runtime library), set it to "" to force loading of the locale tables for X, and then back to the runtime. The idea is that users could change the runtime in their own extension. The solution may be to provide a 'tcl locale type ?settotype?' Tcl level command. -- 10/21/1999 hobbs - foundin initialized to: "obsolete: 8.2b2"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "nobody"
- subsystem initialized to: "57. zlib"
- title initialized to: "Locale support is broken again"
- type initialized to: "RFE"
Ticket change [d94c209758] (rid 107586) by welch on 2000-10-26 08:09:11:
- closedate changed to: "2000-10-26T01:09:11"
- closer changed to: "welch"
- priority changed to: "3 Low"
- resolution changed to: "Fixed"
- status changed to: "Closed"
Ticket change [f8255a0bea] (rid 91489) by dgp on 2001-04-06 03:38:16:
- foundin changed to: "None"
- status changed to: "Open"
- subsystem changed to: "None"
Ticket change [2a62950486] (rid 118559) by dgp on 2001-04-06 03:39:11:
- closedate changed to: "2001-04-05T20:39:11"
- closer changed to: "dgp"
- status changed to: "Closed"
- subsystem changed to: "- New Builtin Commands"