Overview
| Artifact ID: | 57d97b819944c757c0a324361e1b30f889f598b2 |
|---|---|
| Ticket: | 411825ffffffffffffffffffffffffffffffffff
Passing list w/UTF-8 from C can fail |
| User & Date: | dossy on 2003-08-26 07:37:20 |
Changes
- icomment:
Logged In: YES user_id=21885 ====8<==== utfNbspTest.c ====8<==== /* * utfNbspTest.c * * Appending an element to a previous element that ends with the * sequence 0xC2A0 (or \302\240), the UTF code for NO- BREAK SPACE, * results in an incorrect list. * * $ gcc -o utfNbspTest utfNbspTest.c -L/path/to/libtcl8.4.* - ltcl8.4 * */ #include <tcl.h> int TestCmd(ClientData clientData, Tcl_Interp *interp, int argc, char **argv) { Tcl_AppendElement(interp, "foo\302\240"); Tcl_AppendElement(interp, "bar"); return TCL_OK; } int My_AppInit(Tcl_Interp *interp) { Tcl_CreateCommand(interp, "TestCmd", (Tcl_CmdProc *) TestCmd, NULL, NULL); return TCL_OK; } int main(int argc, char **argv) { Tcl_Main(argc, argv, My_AppInit); Tcl_Exit(0); /* NOTREACHED */ return 0; } ====8<==== utfNbspTest.c ====8<==== Here's the transcript showing the error: $ ./utfNbspTest % set tcl_patchLevel 8.4.4 % encoding system utf-8 % encoding system utf-8 % set x [TestCmd] foo bar % llength $x 1 % string length $x 7 % string bytelength $x 8 % exit Of course, yes I know: 1) I should Tcl_Obj'ify everything. 2) Tcl_AppendElement is deprecated (supposedly!) However, I'm dealing with a good amount of legacy code that will eventually get changed/modernized, but for now, it needs to work. If Tcl >8.1 isn't backward compatible, that's fine. But, to call Tcl_AppendElement "deprecated" when it isn't backward compatible, well ... that's just wrong. -- Dossy - login: "dossy"
- mimetype: "text/plain"
- username: "dossy"