Overview
| Artifact ID: | e4bc921c0dc28052a1885a1c50760eeccf78bdaa |
|---|---|
| Ticket: | 411825ffffffffffffffffffffffffffffffffff
Passing list w/UTF-8 from C can fail |
| User & Date: | arobert3434 on 2001-03-28 06:36:18 |
Changes
- assignee changed to: "nobody"
- cmimetype changed to: "text/plain"
- comment changed to:
On certain installations of Tcl/Tk 8.3.1, the passing of UTF-8 character-triplets ending in octal 240 (decimal 160, hex A0) interferes with list delimitation when Tcl_AppendElement is used to return a result from a C function. In particular, if a UTF-8 string ending in octal 240 is appended to the result, and then another UTF-8 string is appended afterwards, the octal 240 seems to be interpreted as a "forward delete" character of some kind, with the result that the separation between the two list elements is erased and they are interpreted as one. The following C function, when called from Tcl, illustrates the problem. int sendCharList(ClientData clientData, Tcl_Interp *interp, int argc, char **argv) { char s1[5], s2[5], s3[5], s4[5]; strcpy(s1, "\345\220\240"); strcpy(s2, "\345\214\240"); strcpy(s3, "\351\235\240"); strcpy(s4, "\347\264\240"); Tcl_ResetResult(interp); Tcl_AppendElement(interp, s1); Tcl_AppendElement(interp, s2); Tcl_AppendElement(interp, s3); Tcl_AppendElement(interp, s4); return TCL_OK; } The Tcl calls: set s6 [sendCharList] puts "[llength $s6] , [string length $s6]" should output "4 , 7" (4 list elements, each a single UTF-8 composite character plus 3 delimiters). On some systems it does. On others, however, the output is "1 , 4", resulting from deletion of the list delimiters somewhere during passage from C to Tcl. A complete test program involving the above (plus some additional tests and using wish not tclsh) may be accessed at: ftp://zakros.ucsd.edu/arobert/Temp/testTclBug.tgz (it is also attached). A full application that exposes the bug (and led to its discovery) may be found at: http://freshmeat.net/projects/hanzim Unfortunately, I have not been able to isolate why some installations exhibit the bug and some don't. A default SUSE 7.0 Linux installation of 8.3.1 had the problem, while a default Slackware 7.1 installation of the same Tcl/Tk version did not. Maybe it is a compilation flag difference... ? I'm also not sure whether it persists in 8.3.2 or 8.4. - foundin changed to: "obsolete: 8.3.1"
- priority changed to: "5 Medium"
- resolution changed to: "None"
- status changed to: "Open"
- submitter changed to: "arobert3434"
- subsystem changed to: "44. UTF-8 Strings"
- title changed to: "Passing list w/UTF-8 from C can fail"
- type changed to: "Bug"